Skip to content

Commit 7f99fb9

Browse files
jackbotdavidgisbey
authored andcommitted
Add temporary "non_llm_answer" strategy
This strategy (which is configured as the default for this branch) will generate an answer without making any LLM calls. It's for the SREs to be able to do load testing without incurring costs from any LLM providers. The `sleep 20` call emulates the latency that we see in a normal LLM-based strategy.
1 parent 65b0a83 commit 7f99fb9

3 files changed

Lines changed: 24 additions & 11 deletions

File tree

app/jobs/answer_analysis/tag_topics_job.rb

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,23 @@ def perform(answer_id)
1010
end
1111
return if quota_limit_reached?
1212

13-
result = AutoEvaluation::TopicTagger.call(answer.question_used)
13+
if Rails.configuration.answer_strategy == "non_llm_answer"
14+
# Temporary strategy for SREs to load test without incurring LLM costs
15+
sleep 10
16+
else
17+
result = AutoEvaluation::TopicTagger.call(answer.question_used)
1418

15-
topics = answer.build_topics(
16-
status: result.status,
17-
primary_topic: result.primary_topic,
18-
secondary_topic: result.secondary_topic,
19-
error_message: result.error_message,
20-
)
21-
topics.assign_metrics("topic_tagger", result.metrics)
22-
topics.assign_llm_response("topic_tagger", result.llm_response)
19+
topics = answer.build_topics(
20+
status: result.status,
21+
primary_topic: result.primary_topic,
22+
secondary_topic: result.secondary_topic,
23+
error_message: result.error_message,
24+
)
25+
topics.assign_metrics("topic_tagger", result.metrics)
26+
topics.assign_llm_response("topic_tagger", result.llm_response)
2327

24-
topics.save!
28+
topics.save!
29+
end
2530
end
2631
end
2732
end

config/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class Application < Rails::Application
8585

8686
config.bigquery_dataset_id = ENV["BIGQUERY_DATASET"]
8787

88-
config.answer_strategy = ENV.fetch("ANSWER_STRATEGY", "claude_structured_answer")
88+
config.answer_strategy = "non_llm_answer"
8989

9090
config.question_topics = GovukChatPrivate.config
9191
.llm_prompts

lib/answer_composition/composer.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ def compose_answer
4545
Pipeline::StructuredAnswerComposer,
4646
Pipeline::AnswerGuardrails,
4747
])
48+
when "non_llm_answer"
49+
# Temporary strategy for SREs to load test without incurring LLM costs
50+
sleep 20
51+
context = Pipeline::Context.new(question)
52+
context.abort_pipeline(
53+
message: Answer::CannedResponses::LLM_CANNOT_ANSWER_MESSAGE,
54+
status: "answered",
55+
)
4856
else
4957
raise "Answer strategy #{answer_strategy} not configured"
5058
end

0 commit comments

Comments
 (0)