mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-12-18 02:27:10 +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
|
||||
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
|
||||
result_list = search(q, n=1, t=SearchType.Org, r=True)
|
||||
collated_result = "\n".join([item.entry for item in result_list])
|
||||
|
@ -58,6 +62,10 @@ def summarize_beta(q: str):
|
|||
gpt_response = str(e)
|
||||
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}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue