Skip to content

Commit

Permalink
debug double response fix (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhirenmathur authored Dec 3, 2024
1 parent 62148e4 commit 619b9ff
Showing 1 changed file with 31 additions and 30 deletions.
61 changes: 31 additions & 30 deletions app/modules/intelligence/agents/chat_agents/debugging_chat_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,37 +170,38 @@ async def run(
)
yield json.dumps({"citations": citations, "message": result})

full_query = f"Query: {query}\nProject ID: {project_id}\nLogs: {logs}\nStacktrace: {stacktrace}"
inputs = {
"history": validated_history,
"tool_results": tool_results,
"input": full_query,
}

logger.debug(f"Inputs to LLM: {inputs}")
citations = self.agents_service.format_citations(citations)
full_response = ""
async for chunk in self.chain.astream(inputs):
content = chunk.content if hasattr(chunk, "content") else str(chunk)
full_response += content
self.history_manager.add_message_chunk(
conversation_id,
content,
MessageType.AI_GENERATED,
citations=citations,
)
yield json.dumps(
{
"citations": citations,
"message": content,
}
)
if classification != ClassificationResult.AGENT_REQUIRED:
full_query = f"Query: {query}\nProject ID: {project_id}\nLogs: {logs}\nStacktrace: {stacktrace}"
inputs = {
"history": validated_history,
"tool_results": tool_results,
"input": full_query,
}

logger.debug(f"Inputs to LLM: {inputs}")
citations = self.agents_service.format_citations(citations)
full_response = ""
async for chunk in self.chain.astream(inputs):
content = chunk.content if hasattr(chunk, "content") else str(chunk)
full_response += content
self.history_manager.add_message_chunk(
conversation_id,
content,
MessageType.AI_GENERATED,
citations=citations,
)
yield json.dumps(
{
"citations": citations,
"message": content,
}
)

logger.debug(f"Full LLM response: {full_response}")

logger.debug(f"Full LLM response: {full_response}")

self.history_manager.flush_message_buffer(
conversation_id, MessageType.AI_GENERATED
)
self.history_manager.flush_message_buffer(
conversation_id, MessageType.AI_GENERATED
)

except Exception as e:
logger.error(
Expand Down

0 comments on commit 619b9ff

Please sign in to comment.