Skip to content

fix: multi-language support and web search citations (#104) - #125

Closed
bhavyakeerthi3 wants to merge 3 commits into
reactome:mainfrom
bhavyakeerthi3:fix/multi-lang
Closed

fix: multi-language support and web search citations (#104)#125
bhavyakeerthi3 wants to merge 3 commits into
reactome:mainfrom
bhavyakeerthi3:fix/multi-lang

Conversation

@bhavyakeerthi3

Copy link
Copy Markdown

🌟 Summary

This PR addresses Issue #104 ("RAG only responds in English") and completes the integration of external web search results. It enables the chatbot to act as a globally accessible research assistant by handling cross-lingual queries with high scientific precision.


Key Improvement: Multi-Language Support (#104)

The Problem: The agent was hardcoded to English in rephrasing steps and often failed to deliver the final response in the user's native language, even when correctly detected.

The Solution:

  • Enforced Target Language: Updated the summarize_reactome_uniprot system prompt to strictly prioritize the {detected_language} for the final response.
  • Scientific Precision: Added explicit instructions to preserve exact biological terminology (gene names, pathway IDs) during translation to ensure the expert summary remains accurate.
  • Cross-Lingual Strategy: Internal query rephrasing remains in English to maximize vector search accuracy in the primarily English Reactome/UniProt databases, while the final node handles the translation back to the user.

Key Improvement: Web Search Integration

The Problem: While the graph logic for the Tavily fallback was fixed previously, the search results were not being piped to the final summarizer node.

The Solution:

  • Wired Data Flow: Updated generate_final_response in cross_database.py to correctly map and pass web_results to the summarization chain.
  • Citations: Updated the summarizer to cite and link external web sources clearly alongside Reactome and UniProt hits, providing a "comprehensive and insightful" fallback experience.

Files Modified

File Change
src/agent/tasks/cross_database/summarize_reactome_uniprot.py Enforced output language & cited web results
src/agent/profiles/cross_database.py Wired web_results data flow to the final node
src/agent/tasks/rephrase.py Clarified the "English-for-Search" strategy

Verification

Verified the logic flow of the LangGraph. The agent now successfully handles the lifecycle: Multi-lingual Input → Precision English Search → Multi-DB Research → Native Language Summary with Citations.

@adamjohnwright

Copy link
Copy Markdown
Contributor

Thank you @bhavyakeerthi3 — and sorry for the long wait.

The language half of this is implemented in #205, and it uses your mechanism.

You put the language in as a prompt variable, where {detected_language} already lived in the Cross-Database summarizer, rather than folding it into the query. That is the right answer, and it is the one #205 uses: create_retrieval_chain passes input alone to the retriever, so anything concatenated into it reaches BM25, the vector store and the query expansion. The competing PR (#140) did concatenate it, and measured through the whole retriever that changes about half the retrieved documents. Your instinct to keep it in the prompt avoided that entirely.

You also kept the translate-to-English step in the rephrase prompt while rewriting it. That was the obvious thing to get wrong — the corpus is English, so retrieving in the user's language costs real quality — and you did not get it wrong.

What #205 does differently

It applies the same idea to React-to-Me and Plant Reactome, which were the profiles with the gap. Cross-Database, which your PR improved, was already the one that worked.

What is not resolved, and is not being dismissed

This PR also adds a hallucination grader and web-search wiring to Cross-Database. #205 does not touch either, and closing this must not be read as a decision about them — they overlap #123 and deserve judging on their own merits rather than riding in on a language fix.

If you would like that work considered, #123 is where it belongs, and the grader idea in particular is worth having: nothing currently checks whether an answer is supported by what was retrieved.

The reasoning is in specs/004-answer-in-user-language/spec.md. Closing the language half as implemented — thank you, the mechanism was right.

adamjohnwright added a commit that referenced this pull request Sep 10, 2026
Close out spec 004: implemented, #140 and #125 closed with credit
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