Skip to content

Integrate langchain-google Search Tool with Grounding Metadata Support #9

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

msaadg
Copy link

@msaadg msaadg commented Jun 3, 2025

This PR updates the backend to use the langchain-google search tool, which now supports grounding metadata, replacing the native Google Search API in the web_research node of graph.py. The change ensures compatibility with the new tool's response structure, particularly for handling grounding metadata. Corresponding updates in utils.py were made to process the response_metadata["grounding_metadata"]["grounding_chunks"] field for URL resolution and citation generation. The application has been tested to verify the changes work as expected.

Changes:

  • Modified backend/src/agent/graph.py:
    • Updated web_research node to use ChatGoogleGenerativeAI with the langchain-google search tool (GenAITool).
    • Adjusted grounding metadata access to response.response_metadata["grounding_metadata"]["grounding_chunks"].
  • Modified backend/src/agent/utils.py:
    • Updated resolve_urls and get_citations to handle the new metadata structure from langchain-google.
  • Modified backend/pyproject.toml:
    • Added google-ai-generativelanguage>=0.6.18 to the project dependencies to ensure compatibility with the new search tool.
  • Verified functionality by running the application.

Testing:

  • Ran the application locally and confirmed that the search functionality and citation generation work correctly with the new tool. Also monitored the logs closely (no issues found).
Screenshot 2025-06-04 at 12 17 13 AM

Related Issues:

  • None

Checklist:

  • Code changes tested locally
  • No breaking changes introduced

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.

1 participant