-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add try/except logic to safely parse JSON objects #65
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the JSON changes here, thank you for working on this.
Could you update your branch and take a look at my comment regarding some of the code removal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this file has some conflicts. These changes have landed already.
Could you update your branch to reflect what's in main? Something like this:
git checkout fix-try-except-json
git fetch upstream
git merge upstream/main
agent_gateway/gateway/planner.py
Outdated
|
||
async def plan(self, inputs: dict, is_replan: bool, **kwargs: Any): | ||
llm_response = await self.run_llm( | ||
inputs=inputs, | ||
is_replan=is_replan, | ||
) | ||
llm_response = llm_response + "\n" | ||
plan_response = self.output_parser.parse(llm_response) | ||
return plan_response | ||
|
||
async def aplan( | ||
self, | ||
inputs: dict, | ||
task_queue: asyncio.Queue[Optional[str]], | ||
is_replan: bool, | ||
**kwargs: Any, | ||
) -> Plan: | ||
"""Given input, asynchronously decide what to do.""" | ||
aplan_response = self.run_llm(inputs=inputs, is_replan=is_replan) | ||
await aplan_response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need this code still. This is used here:
from agent_gateway.gateway.planner import Planner |
orchestration-framework/agent_gateway/gateway/gateway.py
Lines 163 to 170 in b1d6016
self.planner = Planner( | |
session=snowflake_connection, | |
llm=planner_llm, | |
example_prompt=planner_example_prompt, | |
example_prompt_replan=planner_example_prompt_replan, | |
tools=tools, | |
stop=planner_stop, | |
) |
self.planner.aplan( |
tasks = await self.planner.plan( |
Closing in favor of #71 |
This PR introduces a try/except block to handle JSON decoding errors in the _parse_snowflake_response function.
Let me know if any further changes are required!