-
Notifications
You must be signed in to change notification settings - Fork 3
Add answer relevancy models and integrate into analysis workflow #713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
davidgisbey
merged 7 commits into
main
from
add-metrics-data-models-and-integrate-into-workflow
Jan 7, 2026
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a3c1e4b
Add AnswerRelevancyAggregate & AnswerRelevancyRun
davidgisbey 73780fd
Add additional bedrock stub to stub all answer relevancy calls
davidgisbey f8fb85e
Add auto_evaluation_results_creatable concern
davidgisbey ccbda92
Add AnswerAnalysis AnswerRelevancy and Base jobs
davidgisbey 9ace316
Integraate Answer Relevancy Analysis into analysis workflow
davidgisbey 6f36362
Expose answer relevancy metrics in admin UI
davidgisbey 4cabe13
Add Answer#question_used
davidgisbey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| module AnswerAnalysis | ||
| class AnswerRelevancyAggregate < ApplicationRecord | ||
| self.table_name = "answer_analysis_answer_relevancy_aggregates" | ||
|
|
||
| belongs_to :answer | ||
| has_many :runs, | ||
| -> { order(:created_at) }, | ||
| class_name: "AnswerAnalysis::AnswerRelevancyRun", | ||
| foreign_key: :answer_analysis_answer_relevancy_aggregate_id | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| module AnswerAnalysis | ||
| class AnswerRelevancyRun < ApplicationRecord | ||
| include LlmCallsRecordable | ||
|
|
||
| self.table_name = "answer_analysis_answer_relevancy_runs" | ||
|
|
||
| belongs_to :aggregate, | ||
| class_name: "AnswerAnalysis::AnswerRelevancyAggregate", | ||
| foreign_key: :answer_analysis_answer_relevancy_aggregate_id | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| class AddAnswerRelevancyTables < ActiveRecord::Migration[8.0] | ||
| def change | ||
| create_table :answer_analysis_answer_relevancy_aggregates, id: :uuid do |t| | ||
| t.decimal :mean_score, null: false | ||
| t.references :answer, type: :uuid, null: false, foreign_key: { on_delete: :cascade }, index: { unique: true } | ||
| t.timestamps | ||
| end | ||
|
|
||
| create_table :answer_analysis_answer_relevancy_runs, id: :uuid do |t| | ||
| t.decimal :score, null: false | ||
| t.string :reason, null: false | ||
| t.jsonb :llm_responses | ||
| t.jsonb :metrics | ||
| t.references :answer_analysis_answer_relevancy_aggregate, type: :uuid, null: false, foreign_key: { on_delete: :cascade } | ||
| t.timestamps | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| FactoryBot.define do | ||
| factory :answer_relevancy_aggregate, class: "AnswerAnalysis::AnswerRelevancyAggregate" do | ||
| answer | ||
| mean_score { 0.5 } | ||
|
davidgisbey marked this conversation as resolved.
|
||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| FactoryBot.define do | ||
| factory :answer_relevancy_run, class: "AnswerAnalysis::AnswerRelevancyRun" do | ||
| association :aggregate, factory: :answer_relevancy_aggregate | ||
| score { 0.5 } | ||
| reason { "The answer was okay." } | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| RSpec.describe AnswerAnalysis::AnswerRelevancyRun do | ||
| include_examples "llm calls recordable" do | ||
| let(:model) { build(:answer_relevancy_run) } | ||
| end | ||
| end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.