Migration lego-hunter to Tinyfish SDK #177
Migration lego-hunter to Tinyfish SDK #177KrishnaAgarwal7531 wants to merge 1 commit intotinyfish-io:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
simantak-dabhade
left a comment
There was a problem hiding this comment.
Thanks for the migration @KrishnaAgarwal7531! SDK integration looks solid — client.agent.stream() with parallel Promise.allSettled, client.search.query() for retailer discovery.
Blocker: build fails — TypeScript error
npm run build fails:
./app/api/search-lego/route.ts:98:49
Type error: Property 'replace' does not exist on type 'never'.
The SDK types CompleteEvent.result as Record<string, unknown> | null (never string). The typeof raw === "string" branch on line 96 narrows to never, and .replace() fails. Please fix so the build passes.
Minor (non-blocking)
- Stale comment —
route.ts:141says// Analyze best deal from results using Groqbut the code is pure in-memory price comparison (no Groq involved).
What looks good ✓
- SDK usage:
client.agent.stream(),client.search.query(), properEventType/RunStatus - SDK instantiated inside handlers, not module-level
.env.examplecorrect with canonical URL- README accurate
- No Groq, no Mino, no hardcoded secrets
- Clean UI — no shadcn boilerplate dump
Migrates Lego Restock Hunter from OpenAI-based URL generation to the TinyFish SDK, removing the @ai-sdk/openai and ai dependencies entirely.
The original generate-urls route used GPT-4o-mini to hallucinate search URLs for 15 hardcoded retailers — results were often wrong or outdated. The new /api/discover-retailers runs two parallel TinyFish Search queries targeted at the specific LEGO set name, finding real current product pages across retailers without any LLM involvement.
/api/search-lego replaces the raw Mino SSE fetch with client.agent.stream — typed EventType.STREAMING_URL, EventType.PROGRESS, EventType.COMPLETE + RunStatus.COMPLETED, with result content validation. Deal analysis is now built-in price sorting logic rather than a second GPT-4o-mini call — no LLM needed to determine which price is lower.