Skip to content

added new prompt to topic relevance#121

Merged
rkritika1508 merged 1 commit into
mainfrom
feat/topic-relevance-prompts
May 22, 2026
Merged

added new prompt to topic relevance#121
rkritika1508 merged 1 commit into
mainfrom
feat/topic-relevance-prompts

Conversation

@rkritika1508
Copy link
Copy Markdown
Collaborator

@rkritika1508 rkritika1508 commented May 21, 2026

Summary

Target issue is #122.
Explain the motivation for making this change. What existing problem does the pull request solve?
Added two prompts for topic relevance -

  • v2.md — New prompt template for forbidden-topics-only configuration. Scores messages based purely on exclusion logic: forbidden topics score 1, clearly safe messages score 3. Useful when the bot has no allowed-topic allowlist, only a blocklist (e.g. Sneha's gender detection use case).
  • v3.md — New prompt template for mixed allowed + forbidden configuration. Forbidden topics take priority (score 1), then allowed topics are checked (score 3), with ambiguous/overlapping cases landing at 2. Useful when both an allowlist and a blocklist are defined.
  • These complement the existing v1.md (allowed-topics-only) without any DB schema changes — callers simply set prompt_schema_version: 2 or 3 on their topic_relevance config row.

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

Notes

Please add here if any other information is required for the reviewer.

Summary by CodeRabbit

  • New Features

    • Enhanced query classification system with improved topic relevance assessment for more accurate content validation and filtering.
  • Chores

    • Updated scope validation configuration with new scoring parameters for improved message assessment.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

📝 Walkthrough

Walkthrough

This PR introduces two versions of scope classifier prompts for evaluating WhatsApp bot message relevance against configured topic restrictions. Both prompts use a 3-point scoring rubric and include instructions to evaluate messages against forbidden and allowed topics while ignoring override attempts.

Changes

Topic Scope Classification

Layer / File(s) Summary
Scope classifier prompts (v2 and v3)
backend/app/core/validators/prompts/topic_relevance/v2.md, backend/app/core/validators/prompts/topic_relevance/v3.md
Two prompt versions define scope classification logic with 3-point scoring rubrics for determining whether messages fall within forbidden topic exclusions or allowed scopes. Both are parameterized with {{TOPIC_CONFIGURATION}} and include explicit evaluation order (forbidden-first in v3) and instructions to reject scope override attempts.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A rabbit whispers scope divine,
Score three in bounds, score one the line—
For ambiguity, two shall reign,
No tricks can override our domain!
These prompts guard messages with care,
Topic validation everywhere! 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding two new prompt templates (v2.md and v3.md) to the topic_relevance prompt directory.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/topic-relevance-prompts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rkritika1508 rkritika1508 linked an issue May 22, 2026 that may be closed by this pull request
@rkritika1508 rkritika1508 merged commit 32918ee into main May 22, 2026
2 checks passed
@rkritika1508 rkritika1508 deleted the feat/topic-relevance-prompts branch May 22, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Evaluation: Enhance topic relevance prompt

2 participants