Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -594,18 +594,20 @@ async def followup_agent(query: FollowupQueryModel, background_tasks: Background
|
|
594 |
limited_conversation = conversations[query.conversation_id]
|
595 |
|
596 |
|
597 |
-
def process_response():
|
598 |
yield "<followup-response>\n\n"
|
599 |
full_response = ""
|
600 |
for content in chat_with_llama_stream(limited_conversation, model=query.model_id):
|
601 |
full_response += content
|
602 |
yield content
|
603 |
-
|
604 |
yield "</followup-response>\n\n"
|
605 |
|
606 |
logger.info(f"LLM RAW response for query: {query.query}: {full_response}")
|
607 |
-
response_content, interact,tools = parse_followup_and_tools(full_response)
|
608 |
|
|
|
|
|
|
|
|
|
609 |
result = {
|
610 |
"clarification": interact
|
611 |
}
|
@@ -616,7 +618,6 @@ async def followup_agent(query: FollowupQueryModel, background_tasks: Background
|
|
616 |
|
617 |
# Add the assistant's response to the conversation history
|
618 |
conversations[query.conversation_id].append({"role": "assistant", "content": full_response})
|
619 |
-
|
620 |
background_tasks.add_task(update_db, query.user_id, query.conversation_id, query.query, full_response)
|
621 |
logger.info(f"Completed followup agent response for query: {query.query}, send result: {result}")
|
622 |
|
|
|
594 |
limited_conversation = conversations[query.conversation_id]
|
595 |
|
596 |
|
597 |
+
async def process_response():
|
598 |
yield "<followup-response>\n\n"
|
599 |
full_response = ""
|
600 |
for content in chat_with_llama_stream(limited_conversation, model=query.model_id):
|
601 |
full_response += content
|
602 |
yield content
|
|
|
603 |
yield "</followup-response>\n\n"
|
604 |
|
605 |
logger.info(f"LLM RAW response for query: {query.query}: {full_response}")
|
|
|
606 |
|
607 |
+
# Add a slight delay after sending the full LLM response
|
608 |
+
await asyncio.sleep(0.001)
|
609 |
+
|
610 |
+
response_content, interact, tools = parse_followup_and_tools(full_response)
|
611 |
result = {
|
612 |
"clarification": interact
|
613 |
}
|
|
|
618 |
|
619 |
# Add the assistant's response to the conversation history
|
620 |
conversations[query.conversation_id].append({"role": "assistant", "content": full_response})
|
|
|
621 |
background_tasks.add_task(update_db, query.user_id, query.conversation_id, query.query, full_response)
|
622 |
logger.info(f"Completed followup agent response for query: {query.query}, send result: {result}")
|
623 |
|