-
Notifications
You must be signed in to change notification settings - Fork 3
Validator: Answer relevance custom LLM judge #109
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
Open
rkritika1508
wants to merge
14
commits into
main
Choose a base branch
from
feat/answer-relevance-llm-judge
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5e230c2
Added answer relevance validator
rkritika1508 474245b
Added documentation
rkritika1508 64e40aa
added tests
rkritika1508 c581a37
Merge branch 'main' into feat/answer-relevance-llm-judge
rkritika1508 52ae691
Merge branch 'main' into feat/answer-relevance-llm-judge
rkritika1508 569bfc3
Merge branch 'main' into feat/answer-relevance-llm-judge
rkritika1508 ffeb8ae
Merge branch 'main' into feat/answer-relevance-llm-judge
rkritika1508 136293a
merged topic_relevance and answer_relevance
rkritika1508 12a9126
added readme
rkritika1508 707a30d
resolved comments
rkritika1508 41f3873
resolved comments
rkritika1508 13c549b
resolved comment
rkritika1508 8cd8a3d
added output text
rkritika1508 e94d210
Merge branch 'main' into feat/answer-relevance-llm-judge
rkritika1508 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
104 changes: 104 additions & 0 deletions
104
backend/app/alembic/versions/008_added_llm_validator_prompt.py
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,104 @@ | ||
| """Added llm_validator_prompt: rename topic_relevance to llm_prompt, add validator_name, rename configuration to llm_prompt | ||
|
|
||
| Revision ID: 008 | ||
| Revises: 007 | ||
| Create Date: 2026-05-08 00:00:00.000000 | ||
|
|
||
| """ | ||
|
|
||
| from typing import Sequence, Union | ||
|
|
||
| import sqlalchemy as sa | ||
| from alembic import op | ||
|
|
||
| revision: str = "008" | ||
| down_revision = "007" | ||
| branch_labels: Union[str, Sequence[str], None] = None | ||
| depends_on: Union[str, Sequence[str], None] = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| # Rename table | ||
| op.rename_table("topic_relevance", "llm_prompt") | ||
|
|
||
| # Rename indexes created by migration 006 | ||
| op.execute( | ||
| "ALTER INDEX idx_topic_relevance_organization RENAME TO idx_llm_prompt_organization" | ||
| ) | ||
| op.execute( | ||
| "ALTER INDEX idx_topic_relevance_project RENAME TO idx_llm_prompt_project" | ||
| ) | ||
| op.execute( | ||
| "ALTER INDEX idx_topic_relevance_prompt_schema_version " | ||
| "RENAME TO idx_llm_prompt_prompt_schema_version" | ||
| ) | ||
| op.execute( | ||
| "ALTER INDEX idx_topic_relevance_is_active RENAME TO idx_llm_prompt_is_active" | ||
| ) | ||
|
|
||
| # Add validator_name column (server_default backfills existing rows as topic_relevance) | ||
| op.add_column( | ||
| "llm_prompt", | ||
| sa.Column( | ||
| "validator_name", | ||
| sa.String(), | ||
| nullable=False, | ||
| server_default="topic_relevance", | ||
| ), | ||
| ) | ||
| # Drop server_default so future rows must supply validator_name explicitly | ||
| op.alter_column("llm_prompt", "validator_name", server_default=None) | ||
|
|
||
| # Rename configuration → llm_prompt column | ||
| op.alter_column("llm_prompt", "configuration", new_column_name="llm_prompt") | ||
|
|
||
| # Replace unique constraint to include validator_name and use new column name | ||
| op.drop_constraint( | ||
| "uq_topic_relevance_config_org_project_prompt", | ||
| "llm_prompt", | ||
| type_="unique", | ||
| ) | ||
| op.create_unique_constraint( | ||
| "uq_llm_prompt_config", | ||
| "llm_prompt", | ||
| [ | ||
| "organization_id", | ||
| "project_id", | ||
| "validator_name", | ||
| "prompt_schema_version", | ||
| "llm_prompt", | ||
| ], | ||
| ) | ||
|
|
||
| op.create_index("idx_llm_prompt_validator_name", "llm_prompt", ["validator_name"]) | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| op.drop_index("idx_llm_prompt_validator_name", table_name="llm_prompt") | ||
|
|
||
| op.drop_constraint("uq_llm_prompt_config", "llm_prompt", type_="unique") | ||
| op.create_unique_constraint( | ||
| "uq_topic_relevance_config_org_project_prompt", | ||
| "llm_prompt", | ||
| ["organization_id", "project_id", "prompt_schema_version", "llm_prompt"], | ||
| ) | ||
|
|
||
| op.alter_column("llm_prompt", "llm_prompt", new_column_name="configuration") | ||
|
|
||
| op.drop_column("llm_prompt", "validator_name") | ||
|
|
||
| op.execute( | ||
| "ALTER INDEX idx_llm_prompt_is_active RENAME TO idx_topic_relevance_is_active" | ||
| ) | ||
| op.execute( | ||
| "ALTER INDEX idx_llm_prompt_prompt_schema_version " | ||
| "RENAME TO idx_topic_relevance_prompt_schema_version" | ||
| ) | ||
| op.execute( | ||
| "ALTER INDEX idx_llm_prompt_project RENAME TO idx_topic_relevance_project" | ||
| ) | ||
| op.execute( | ||
| "ALTER INDEX idx_llm_prompt_organization RENAME TO idx_topic_relevance_organization" | ||
| ) | ||
|
|
||
| op.rename_table("llm_prompt", "topic_relevance") | ||
28 changes: 28 additions & 0 deletions
28
backend/app/alembic/versions/009_add_output_text_to_request_log.py
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,28 @@ | ||
| """Add output_text to request_log | ||
|
|
||
| Revision ID: 009 | ||
| Revises: 008 | ||
| Create Date: 2026-05-21 00:00:00.000000 | ||
|
|
||
| """ | ||
|
|
||
| from typing import Sequence, Union | ||
|
|
||
| import sqlalchemy as sa | ||
| from alembic import op | ||
|
|
||
| revision: str = "009" | ||
| down_revision = "008" | ||
| branch_labels: Union[str, Sequence[str], None] = None | ||
| depends_on: Union[str, Sequence[str], None] = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| op.add_column( | ||
| "request_log", | ||
| sa.Column("output_text", sa.String(), nullable=True), | ||
| ) | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| op.drop_column("request_log", "output_text") |
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
Oops, something went wrong.
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.