Skip to content

top k parameter Chat API#547

Open
soniyaLama0 wants to merge 2 commits into
param20h:devfrom
soniyaLama0:feature/top-k-parameter
Open

top k parameter Chat API#547
soniyaLama0 wants to merge 2 commits into
param20h:devfrom
soniyaLama0:feature/top-k-parameter

Conversation

@soniyaLama0

Copy link
Copy Markdown

## 📋 PR Checklist

Thank you for contributing to PDF-Assistant-RAG! 🎉
Please fill out this template before submitting. PRs without it filled in will be closed.


🔗 Related Issue

N/A

📝 What does this PR do?

This PR adds a configurable top-k retrieval parameter to the Chat API, allowing the user to dynamically adjust the number of context chunks retrieved during RAG queries.

Specifically, it:

  1. Adds a top_k parameter to the ChatRequest schema.
  2. Updates /ask and /ask/stream endpoints to pass the top_k value down to the retriever.
  3. Adds a "Sources count (Top-K)" slider in the Frontend Chat Settings menu to let users easily configure this value before asking questions.

🗂️ Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🔧 Refactor / code cleanup
  • 📝 Documentation update
  • 🎨 UI / styling change
  • ⚙️ CI / tooling / config change
  • 🧪 Tests

🧪 How was this tested?

  • Ran the backend locally (uvicorn app.main:app --reload)
  • Ran the frontend locally (npm run dev inside frontend/)
  • Tested the affected API endpoints manually
  • Added / updated tests

📸 Screenshots (if UI change)

image Screenshot 2026-06-10 101452

⚠️ Anything to flag for reviewers?

The default fallback for top_k remains unchanged (driven by backend settings) if the frontend does not explicitly provide a value.


✅ Self-Review Checklist

  • My branch is based on dev, not main
  • I have not added any secrets / API keys
  • I have not modified main branch or any HuggingFace deployment config
  • My code follows the existing style (no unnecessary formatting changes)
  • I have updated relevant docs / comments if needed

@soniyaLama0 soniyaLama0 requested a review from param20h as a code owner June 10, 2026 04:59
@soniyaLama0 soniyaLama0 force-pushed the feature/top-k-parameter branch from c250180 to a23561e Compare June 10, 2026 05:04
@param20h

Copy link
Copy Markdown
Owner

mergeeee conflicts

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