mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-24 07:55:07 +01:00
Set conversation type if query param set, else return chat history
Only initialize variables if query is not empty, to avoid unnecessary compute, variable null checks etc. Fixes #230
This commit is contained in:
parent
6224dce49d
commit
e97a20d70c
1 changed files with 9 additions and 9 deletions
|
@ -277,15 +277,6 @@ def chat(q: Optional[str] = None, client: Optional[str] = None):
|
|||
status_code=500, detail="Chat processor not configured. Configure OpenAI API key on server and restart it."
|
||||
)
|
||||
|
||||
# Initialize Variables
|
||||
api_key = state.processor_config.conversation.openai_api_key
|
||||
model = state.processor_config.conversation.model
|
||||
chat_model = state.processor_config.conversation.chat_model
|
||||
user_message_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
conversation_type = "general" if q.startswith("@general") else "notes"
|
||||
compiled_references = []
|
||||
inferred_queries = []
|
||||
|
||||
# Load Conversation History
|
||||
chat_session = state.processor_config.conversation.chat_session
|
||||
meta_log = state.processor_config.conversation.meta_log
|
||||
|
@ -297,6 +288,15 @@ def chat(q: Optional[str] = None, client: Optional[str] = None):
|
|||
else:
|
||||
return {"status": "ok", "response": []}
|
||||
|
||||
# Initialize Variables
|
||||
api_key = state.processor_config.conversation.openai_api_key
|
||||
model = state.processor_config.conversation.model
|
||||
chat_model = state.processor_config.conversation.chat_model
|
||||
user_message_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
conversation_type = "general" if q.startswith("@general") else "notes"
|
||||
compiled_references = []
|
||||
inferred_queries = []
|
||||
|
||||
if conversation_type == "notes":
|
||||
# Infer search queries from user message
|
||||
with timer("Extracting search queries took", logger):
|
||||
|
|
Loading…
Reference in a new issue