Skip to content

Fix RAG chat temperature handling#18

Open
ar-amk wants to merge 2 commits into
aietal:masterfrom
ar-amk:codex/aimengpt-rag-temperature
Open

Fix RAG chat temperature handling#18
ar-amk wants to merge 2 commits into
aietal:masterfrom
ar-amk:codex/aimengpt-rag-temperature

Conversation

@ar-amk
Copy link
Copy Markdown

@ar-amk ar-amk commented May 20, 2026

Part of the open Algora bounty for [ISAAC-497] Implement an enhanced RAG Pipeline for Scientific/Research Workflows.

/claim #45

Bounty reference: https://algora.io/isaac/bounties/clq18zr98000ejs0gt0nv7gwu

Summary

  • Pass the resolved RAG chat temperature into OpenAIStream instead of silently forcing every streamed answer to 0.
  • Add a small server utility for default-temperature fallback behaviour.
  • Safely fall back on the default for missing, NaN, infinite, or out-of-range temperature values.
  • Add focused unit coverage for explicit, omitted, and invalid temperature values.

Why this helps the scientific RAG workflow

Scientific and research workflows often need controlled answer variance: deterministic extraction for evidence-heavy questions, and slightly higher temperature for synthesis or exploration. The UI already collects a temperature setting, but the RAG stream ignored it. This PR makes the existing control actually affect RAG answers while preserving a safe default.

Verification

From ui/:

npx vitest run __tests__/rag-chat-options.test.ts --reporter verbose
npx prettier --check pages/api/rag-chat.ts utils/server/rag-chat-options.ts __tests__/rag-chat-options.test.ts
npx tsc --noEmit --pretty false
npm run lint -- --file pages/api/rag-chat.ts --file utils/server/rag-chat-options.ts --file __tests__/rag-chat-options.test.ts
git diff --check

Results:

  • Targeted Vitest passed: 3 tests
  • Prettier passed
  • TypeScript passed
  • ESLint passed
  • Diff whitespace check 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.

1 participant