|
284 | 284 | .and have_content('"id": "call_dqGpbb39drQDafLsjDLtnbGD"') |
285 | 285 | end |
286 | 286 |
|
287 | | - it "doesn't render the tabs component when there are no topics or auto-eval aggregate data" do |
| 287 | + it "doesn't render the tabs component there is no analysis data" do |
288 | 288 | question = create(:question, :with_answer) |
289 | 289 | get admin_show_question_path(question) |
290 | 290 |
|
|
362 | 362 | end |
363 | 363 | end |
364 | 364 |
|
365 | | - context "when answer relevancy aggregate data is present" do |
366 | | - let(:run) do |
367 | | - create( |
368 | | - :answer_relevancy_run, |
369 | | - score: 0.85, |
370 | | - reason: "The answer is relevant to the question.", |
371 | | - llm_responses: { |
372 | | - "statements" => { "statements" => ["The answer is relevant."] }, |
373 | | - "verdicts" => { "verdicts" => [{ "verdict" => "yes" }] }, |
374 | | - }, |
375 | | - metrics: { |
376 | | - "statements" => { duration: 1.55556 }, |
377 | | - "verdicts" => { duration: 1.44445 }, |
378 | | - }, |
379 | | - ) |
380 | | - end |
381 | | - let(:question) { run.answer.question } |
| 365 | + { |
| 366 | + answer_relevancy_run: "Answer relevancy", |
| 367 | + coherence_run: "Coherence", |
| 368 | + }.each do |model, title| |
| 369 | + context "when answer relevancy aggregate data is present" do |
| 370 | + let(:run) do |
| 371 | + create( |
| 372 | + model, |
| 373 | + score: 0.85, |
| 374 | + reason: "The answer was acceptable.", |
| 375 | + llm_responses: { |
| 376 | + "statements" => { "statements" => ["The answer was acceptable."] }, |
| 377 | + "verdicts" => { "verdicts" => [{ "verdict" => "yes" }] }, |
| 378 | + }, |
| 379 | + metrics: { |
| 380 | + "statements" => { duration: 1.55556 }, |
| 381 | + "verdicts" => { duration: 1.44445 }, |
| 382 | + }, |
| 383 | + ) |
| 384 | + end |
| 385 | + let(:question) { run.answer.question } |
382 | 386 |
|
383 | | - it "renders the answer relevancy aggregate and run details" do |
384 | | - get admin_show_question_path(question) |
| 387 | + it "renders #{model} details" do |
| 388 | + get admin_show_question_path(question) |
385 | 389 |
|
386 | | - expect(response.body.squish) |
387 | | - .to have_content("Answer relevancy") |
388 | | - .and have_content("Run 1 score") |
389 | | - .and have_content("0.85") |
390 | | - .and have_content("Run 1 reason") |
391 | | - .and have_content("The answer is relevant to the question.") |
392 | | - end |
| 390 | + expect(response.body.squish) |
| 391 | + .to have_content(title) |
| 392 | + .and have_content("Mean score 0.85") |
| 393 | + .and have_content("Run 1 score 0.85") |
| 394 | + .and have_content("Run 1 reason The answer was acceptable.") |
| 395 | + end |
393 | 396 |
|
394 | | - it "renders the runs llm responses" do |
395 | | - get admin_show_question_path(question) |
| 397 | + it "renders the runs llm responses" do |
| 398 | + get admin_show_question_path(question) |
396 | 399 |
|
397 | | - expect(response.body.squish) |
398 | | - .to have_content('{ "statements": [ "The answer is relevant." ] }') |
399 | | - .and have_content('{ "verdicts": [ { "verdict": "yes" } ] }') |
400 | | - end |
| 400 | + expect(response.body.squish) |
| 401 | + .to have_content('{ "statements": [ "The answer was acceptable." ] }') |
| 402 | + .and have_content('{ "verdicts": [ { "verdict": "yes" } ] }') |
| 403 | + end |
401 | 404 |
|
402 | | - it "renders the runs metrics" do |
403 | | - get admin_show_question_path(question) |
| 405 | + it "renders the runs metrics" do |
| 406 | + get admin_show_question_path(question) |
404 | 407 |
|
405 | | - expect(response.body.squish) |
406 | | - .to have_content("Statements") |
407 | | - .and have_content(/duration.*1\.55556/) |
408 | | - .and have_content("Verdicts") |
409 | | - .and have_content(/duration.*1\.44445/) |
| 408 | + expect(response.body.squish) |
| 409 | + .to have_content("Statements") |
| 410 | + .and have_content(/duration.*1\.55556/) |
| 411 | + .and have_content("Verdicts") |
| 412 | + .and have_content(/duration.*1\.44445/) |
| 413 | + end |
410 | 414 | end |
411 | 415 | end |
412 | 416 | end |
|
0 commit comments