mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 17:35:07 +01:00
Update /beta/chat API to return chat history if no query param passed
This commit is contained in:
parent
d8ee0f0e9a
commit
cc2456e411
1 changed files with 5 additions and 1 deletions
|
@ -62,7 +62,7 @@ def summarize_beta(q: str):
|
|||
|
||||
|
||||
@api_beta.get('/chat')
|
||||
def chat(q: str):
|
||||
def chat(q: Optional[str]=None):
|
||||
# Initialize Variables
|
||||
model = state.processor_config.conversation.model
|
||||
api_key = state.processor_config.conversation.openai_api_key
|
||||
|
@ -71,6 +71,10 @@ def chat(q: str):
|
|||
chat_session = state.processor_config.conversation.chat_session
|
||||
meta_log = state.processor_config.conversation.meta_log
|
||||
|
||||
# If user query is empty, return chat history
|
||||
if not q:
|
||||
return {'status': 'ok', 'response': meta_log["chat"]}
|
||||
|
||||
# Converse with OpenAI GPT
|
||||
metadata = understand(q, model=model, api_key=api_key, verbose=state.verbose)
|
||||
logger.debug(f'Understood: {get_from_dict(metadata, "intent")}')
|
||||
|
|
Loading…
Reference in a new issue