Update conversation logs from /beta/summary API endpoint too

This commit is contained in:
Debanjum Singh Solanky 2023-01-13 21:22:40 -03:00
parent cb6f0b53c9
commit 330febaa1a

View file

@ -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}