|
24 | 24 | before { context.search_results = [search_result] } |
25 | 25 |
|
26 | 26 | shared_examples "llm cannot answer the question" do |options| |
27 | | - it "aborts the pipeline and sets the answer's status and message correctly" do |
| 27 | + it "aborts the pipeline and sets the answer's attributes correctly" do |
28 | 28 | stub_claude_structured_answer( |
29 | 29 | question.message, |
30 | 30 | "Sorry I cannot answer that question.", |
|
34 | 34 | expect { described_class.call(context) }.to throw_symbol(:abort) |
35 | 35 | .and change { context.answer.status }.to("unanswerable_llm_cannot_answer") |
36 | 36 | .and change { context.answer.message }.to(Answer::CannedResponses::LLM_CANNOT_ANSWER_MESSAGE) |
| 37 | + .and change { context.answer.completeness }.to(options[:answer_completeness]) |
37 | 38 | end |
38 | 39 |
|
39 | 40 | it "sets sources used to false for all sources" do |
|
110 | 111 | end |
111 | 112 | end |
112 | 113 |
|
113 | | - it "uses Claude via Anthropic to assign the correct values to the context's answer" do |
114 | | - answer = "VAT (Value Added Tax) is a tax applied to most goods and services in the UK." |
115 | | - stub_claude_structured_answer(question.message, answer) |
| 114 | + describe "with valid answer_completeness values" do |
| 115 | + %w[complete partial].each do |answer_completeness| |
| 116 | + it "uses Claude via Anthropic to assign the correct values to the context's answer" do |
| 117 | + answer = "VAT (Value Added Tax) is a tax applied to most goods and services in the UK." |
| 118 | + stub_claude_structured_answer(question.message, answer, answer_completeness: answer_completeness) |
116 | 119 |
|
117 | | - described_class.call(context) |
| 120 | + described_class.call(context) |
118 | 121 |
|
119 | | - expect(context.answer.message.squish).to eq(answer) |
120 | | - expect(context.answer) |
121 | | - .to have_attributes(status: "answered", completeness: "complete") |
| 122 | + expect(context.answer.message.squish).to eq(answer) |
| 123 | + expect(context.answer) |
| 124 | + .to have_attributes(status: "answered", completeness: answer_completeness) |
| 125 | + end |
| 126 | + end |
122 | 127 | end |
123 | 128 |
|
124 | 129 | it "stores the LLM response" do |
|
194 | 199 | .and change { context.answer.sources.first.used }.to(false) |
195 | 200 | end |
196 | 201 |
|
197 | | - context "when answered is false" do |
| 202 | + context "when answer_completeness is not a successful value" do |
198 | 203 | include_examples "llm cannot answer the question", { |
199 | 204 | answered: false, |
200 | 205 | sources_used: [], |
201 | | - answer_completeness: "incomplete", |
| 206 | + answer_completeness: "no_information", |
202 | 207 | } |
203 | 208 | end |
204 | 209 |
|
|
0 commit comments