Skip to content

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

@Yoseph-Zuskin
Copy link

Nice, the links weren't working for me but this helped! Seems there is a minor bug in backend/src/agent/utils.py lines 71 to 73, should be changed to this to fix:

        modified_text = (
            "".join(modified_text[:end_idx])
            + marker_to_insert
            + "".join(modified_text[end_idx:])
        )

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