Skip to content

Commit

Permalink
Merge pull request #216 from potpie-ai/stream_agent
Browse files Browse the repository at this point in the history
Handle response format in agent classifier
  • Loading branch information
dhirenmathur authored Dec 20, 2024
2 parents 9f68a2b + 1f4f4da commit 55eb585
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,14 @@ async def classifier_node(self, state: State) -> Command:
agent_descriptions=self.agent_descriptions,
)
response = await self.llm.ainvoke(prompt)

response = response.content.strip("`")
try:
agent_id, confidence = response.content.split("|")
agent_id, confidence = response.split("|")
confidence = float(confidence)
except (ValueError, TypeError):
return Command(
update={"response": "Error in classification format"}, goto=END
)

if confidence < 0.5 or agent_id not in self.agents:
return Command(
update={"agent_id": state["agent_id"]}, goto=state["agent_id"]
Expand Down

0 comments on commit 55eb585

Please sign in to comment.