Skip to content

Add Gemini as LLM provider so proposal analysis works again - #5

Merged
rogerdemello merged 1 commit into
mainfrom
fix/workflow-bugs
Oct 9, 2026
Merged

rogerdemello merged 1 commit into
mainfrom
fix/workflow-bugs

Conversation

@rogerdemello

Copy link
Copy Markdown
Owner

Summary

The Azure OpenAI resource (openai-04.openai.azure.com) no longer resolves in DNS, so every Analyze click returned a 500. This adds Google Gemini as an alternative LLM provider so analysis and generation work again.

  • New src/api/lib/llm.ts: shared chat client. Uses Gemini via its OpenAI-compatible endpoint when GEMINI_API_KEY is set, otherwise Azure OpenAI as before.
  • analyze.ts and proposals.ts use the shared client instead of constructing their own AzureOpenAI.
  • .env.example documents GEMINI_API_KEY / GEMINI_MODEL (default gemini-2.5-flash).

Things to know

  • Gemini 2.5 "thinks" by default and those tokens count against max_tokens, which truncated the JSON reply (Unterminated string in JSON). Fixed with reasoning_effort: "none" and raising the analysis max_tokens from 2000 to 4000.
  • Embeddings (semantic search) are unchanged and still use Azure. With the Azure resource gone they fail gracefully and search falls back to substring matching.
  • Azure behaviour is unchanged when GEMINI_API_KEY is unset.
  • Set GEMINI_API_KEY in Render's environment to use this on the deployed app.

Verification

  • npm run lint, npm run typecheck, npm test (55/55) pass.
  • Ran POST /api/analyze/:id against the "Website Update Proposal" sample on the local server: 200 in ~6s, readiness 30, 7 findings (35% discount over the 25% cap, $5,525 under the $10k minimum, Net 120 over the 90-day limit), 5 recommendations.

The Azure OpenAI resource (openai-04.openai.azure.com) no longer resolves,
so every Analyze click returned a 500. Add a shared chat client that uses
Google Gemini through its OpenAI-compatible endpoint when GEMINI_API_KEY is
set and falls back to Azure OpenAI otherwise.

- src/api/lib/llm.ts: provider selection, model, and extra params
- analyze.ts / proposals.ts: use the shared client; analysis max_tokens
  2000 -> 4000
- Gemini 2.5 thinks by default and those tokens count against max_tokens,
  which truncated the JSON reply; reasoning_effort none avoids it
- .env.example: document GEMINI_API_KEY / GEMINI_MODEL
Copilot AI balanced review requested due to automatic review settings October 9, 2026 10:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@rogerdemello
rogerdemello merged commit 4fdabd2 into main Oct 9, 2026
2 checks passed
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