Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions routes/chatbot_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
chatbot_bp = Blueprint("chatbot", __name__, url_prefix="/chatbot")
MAX_QUESTION_LENGTH = 1_000
MAX_CONTEXT_LENGTH = 4_000
CHATBOT_MAX_OUTPUT_TOKENS = 1_000


@chatbot_bp.route("/ask", methods=["POST"])
Expand Down Expand Up @@ -88,13 +89,15 @@ def ask_question():
"Do not claim that data, diagnostics, or assumptions were tested when "
"they were not. For questions asking what could replace a recommended "
"model, start with the verified compatible alternatives in the page "
"context. Give 3–6 concise bullets, each naming the alternative, when "
"it is preferable, and its main assumption or tradeoff. You may add "
"context. Summarize the answer in at most 120 words with no preamble. "
"Give at most 3 concise bullets, each naming the alternative, when it "
"is preferable, and its main assumption or tradeoff. You may add "
"another model only when the stated design clearly supports it; label "
"it as a conditional option rather than an engine-verified match. End "
"with the most important diagnostic or design fact needed to decide. "
"For other questions, answer concisely and state important assumptions "
"and uncertainty."
"with one short sentence naming the most important diagnostic or "
"design fact needed to decide. For other questions, answer in at most "
"120 words and state only the most important assumptions and "
"uncertainty."
)

try:
Expand All @@ -105,6 +108,7 @@ def ask_question():
prompt,
system_prompt=system_prompt,
safety_identifier=safety_identifier,
max_output_tokens=CHATBOT_MAX_OUTPUT_TOKENS,
)
except OpenAIServiceError as exc:
logger.warning(
Expand Down
5 changes: 4 additions & 1 deletion tests/test_integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,11 @@ def test_chatbot_guides_model_replacement_questions(
assert "What other model can replace" in call.args[0]
system_prompt = call.kwargs["system_prompt"]
assert "verified compatible alternatives" in system_prompt
assert "3–6 concise bullets" in system_prompt
assert "at most 120 words" in system_prompt
assert "at most 3 concise bullets" in system_prompt
assert "with no preamble" in system_prompt
assert "conditional option" in system_prompt
assert call.kwargs["max_output_tokens"] == 1_000


def test_model_recommendation_can_use_ai_review(
Expand Down