Skip to content

feat(chatbot): separate answer instructions from prompt matching (#376)#795

Open
PRAteek-singHWY wants to merge 1 commit intoOWASP:mainfrom
PRAteek-singHWY:fix/376-separate-answer-language-input
Open

feat(chatbot): separate answer instructions from prompt matching (#376)#795
PRAteek-singHWY wants to merge 1 commit intoOWASP:mainfrom
PRAteek-singHWY:fix/376-separate-answer-language-input

Conversation

@PRAteek-singHWY
Copy link
Contributor

@PRAteek-singHWY PRAteek-singHWY commented Mar 7, 2026

Summary

fixes #376

This PR implements issue #376 by separating answer instructions from the user prompt so OpenCRE matching quality is not degraded by language/style directives.

Problem

Previously, language/style directives (for example, "Answer in Chinese") were included in the same prompt text used for embeddings and matching. That made retrieval less accurate.

Changes

  • Frontend: added a separate Instructions input in chatbot UI (default: Answer in English)
  • API: /rest/v1/completion now receives prompt and instructions separately
  • Prompt handler: embeddings are generated from prompt only
  • Completion generation: instructions are applied only to final answer generation
  • Tests:
    • application/tests/prompt_client_test.py
    • application/tests/web_main_test.py::TestMain::test_completion_passes_instructions_separately

Verification

  • venv/bin/python -m pytest application/tests/prompt_client_test.py application/tests/web_main_test.py::TestMain::test_completion_passes_instructions_separately -q
  • yarn build (frontend build passes; only existing webpack size warnings)

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.

Have a separate UI element to enter language request, to prevent requests in the prompt to bother the matching

1 participant