Skip to content

fix: context-aware web search query when PDF files are uploaded#259

Closed
YizukiAme wants to merge 5 commits intoTHU-MAIC:mainfrom
YizukiAme:fix/context-aware-search-query
Closed

fix: context-aware web search query when PDF files are uploaded#259
YizukiAme wants to merge 5 commits intoTHU-MAIC:mainfrom
YizukiAme:fix/context-aware-search-query

Conversation

@YizukiAme
Copy link
Contributor

@YizukiAme YizukiAme commented Mar 24, 2026

This PR was developed in parallel with #258 to address the same issue (#246) — making web search queries context-aware when a PDF is uploaded. Both PRs independently identified the core problem: vague requirements were being sent directly to Tavily, resulting in poor search results.

Our implementation was still being iterated on while #258 has already landed a complete, tested solution covering both the preview and server generation paths. Closing in favor of #258 to avoid duplicate effort. Nice work @nkmohit!

- Extract enhanceSearchQuery into shared module lib/web-search/query-enhancer.ts
- Update /api/web-search route to accept pdfText and enhance query
- Pass pdfText from generation-preview client to web search API
- Refactor classroom-generation.ts to use shared module
…ments

The query enhancer was silently failing because resolveModel({}) requires
server-configured env vars. In client-configured mode (no server model),
the LLM call would throw, get caught by try/catch, and fall back to
the original query - making enhancement never work.

Now the client passes its model config through the API, and the enhancer
uses it to make the LLM call.
@YizukiAme YizukiAme force-pushed the fix/context-aware-search-query branch from 04fa1c1 to d27f858 Compare March 24, 2026 19:32
@YizukiAme YizukiAme closed this Mar 24, 2026
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