Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging agent double response fix #202

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading