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

Add try/except logic to safely parse JSON objects #65

Closed
wants to merge 14 commits into from

Conversation

GovindHede
Copy link
Contributor

This PR introduces a try/except block to handle JSON decoding errors in the _parse_snowflake_response function.

  • Ensures that invalid JSON objects are logged without breaking the application flow.
  • Addresses feedback from maintainers regarding improved error handling for json.loads.

Let me know if any further changes are required!

@sfc-gh-twhite sfc-gh-twhite self-requested a review November 27, 2024 13:18
Copy link
Collaborator

@sfc-gh-twhite sfc-gh-twhite left a 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?

Copy link
Collaborator

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

Comment on lines 285 to 320

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
Copy link
Collaborator

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

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,
)

tasks = await self.planner.plan(

@sfc-gh-twhite
Copy link
Collaborator

Closing in favor of #71

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants