mirror of
https://github.com/khoj-ai/khoj.git
synced 2025-02-17 16:14:21 +00:00
Update conversation logs from /beta/summary API endpoint too
This commit is contained in:
parent
cb6f0b53c9
commit
330febaa1a
1 changed files with 8 additions and 0 deletions
|
@ -47,6 +47,10 @@ def summarize_beta(q: str):
|
||||||
model = state.processor_config.conversation.model
|
model = state.processor_config.conversation.model
|
||||||
api_key = state.processor_config.conversation.openai_api_key
|
api_key = state.processor_config.conversation.openai_api_key
|
||||||
|
|
||||||
|
# Load Conversation History
|
||||||
|
chat_session = state.processor_config.conversation.chat_session
|
||||||
|
meta_log = state.processor_config.conversation.meta_log
|
||||||
|
|
||||||
# Converse with OpenAI GPT
|
# Converse with OpenAI GPT
|
||||||
result_list = search(q, n=1, t=SearchType.Org, r=True)
|
result_list = search(q, n=1, t=SearchType.Org, r=True)
|
||||||
collated_result = "\n".join([item.entry for item in result_list])
|
collated_result = "\n".join([item.entry for item in result_list])
|
||||||
|
@ -58,6 +62,10 @@ def summarize_beta(q: str):
|
||||||
gpt_response = str(e)
|
gpt_response = str(e)
|
||||||
status = 'error'
|
status = 'error'
|
||||||
|
|
||||||
|
# Update Conversation History
|
||||||
|
state.processor_config.conversation.chat_session = message_to_prompt(q, chat_session, gpt_message=gpt_response)
|
||||||
|
state.processor_config.conversation.meta_log['chat'] = message_to_log(q, gpt_response, conversation_log=meta_log.get('chat', []))
|
||||||
|
|
||||||
return {'status': status, 'response': gpt_response}
|
return {'status': status, 'response': gpt_response}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue