-
Notifications
You must be signed in to change notification settings - Fork 2
Topic relevance validator #71
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
Merged
Changes from 8 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
9ae1fb7
added llm critic validator
rkritika1508 76f98f7
Added topic relevance validator
rkritika1508 d717740
updated topic relevance validator code
rkritika1508 dfb3c03
added alembic for topic relevance table
rkritika1508 9d7d6dc
added tests
rkritika1508 aaa2e7d
changed configuration type from json to string
rkritika1508 dfeff2a
fixed ci
rkritika1508 4cf6b86
fixed ci
rkritika1508 d8fe009
updated ci
rkritika1508 1090a96
removed ci file
rkritika1508 efa3641
resolved comments
rkritika1508 2813efb
resolved comment
rkritika1508 6916fb4
fixed tests
rkritika1508 7a770e8
fixed bug
rkritika1508 ca44f62
updated prompt
rkritika1508 540b930
Merge branch 'main' into feat/llm-critic
rkritika1508 baa13b1
resolved comments
rkritika1508 26c43f6
resolved comments
rkritika1508 4b14581
fixed test
rkritika1508 9bd379a
resolved comments
rkritika1508 faa0cfd
Resolved comments
rkritika1508 50a6c4b
resolved comment
rkritika1508 7f99434
resolved comments
rkritika1508 638ed26
refactored guardrails code
rkritika1508 1ccce38
fixed test
rkritika1508 c4b11d0
resolved comments
rkritika1508 d8c36fc
resolved comment
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
Some comments aren't visible on the classic Files Changed page.
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
54 changes: 54 additions & 0 deletions
54
backend/app/alembic/versions/006_added_topic_relevance_config.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,54 @@ | ||
| """Added topic_relevance table | ||
|
|
||
| Revision ID: 006 | ||
| Revises: 005 | ||
| Create Date: 2026-03-05 00:00:00.000000 | ||
|
|
||
| """ | ||
|
|
||
| from typing import Sequence, Union | ||
|
|
||
| from alembic import op | ||
| import sqlalchemy as sa | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision: str = "006" | ||
| down_revision = "005" | ||
| branch_labels: Union[str, Sequence[str], None] = None | ||
| depends_on: Union[str, Sequence[str], None] = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| op.create_table( | ||
| "topic_relevance", | ||
| sa.Column("id", sa.Uuid(), nullable=False), | ||
| sa.Column("organization_id", sa.Integer(), nullable=False), | ||
| sa.Column("project_id", sa.Integer(), nullable=False), | ||
| sa.Column("name", sa.String(), nullable=False), | ||
| sa.Column("description", sa.String(), nullable=False), | ||
rkritika1508 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| sa.Column("prompt_version", sa.Integer(), nullable=False), | ||
| sa.Column("configuration", sa.Text(), nullable=False), | ||
| sa.Column("is_active", sa.Boolean(), nullable=False, server_default=sa.true()), | ||
| sa.Column("created_at", sa.DateTime(), nullable=False), | ||
| sa.Column("updated_at", sa.DateTime(), nullable=False), | ||
| sa.PrimaryKeyConstraint("id"), | ||
| sa.UniqueConstraint( | ||
| "name", | ||
| "organization_id", | ||
| "project_id", | ||
| name="uq_topic_relevance_name_org_project", | ||
| ), | ||
rkritika1508 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| op.create_index( | ||
| "idx_topic_relevance_organization", "topic_relevance", ["organization_id"] | ||
| ) | ||
| op.create_index("idx_topic_relevance_project", "topic_relevance", ["project_id"]) | ||
| op.create_index( | ||
| "idx_topic_relevance_prompt_version", "topic_relevance", ["prompt_version"] | ||
| ) | ||
| op.create_index("idx_topic_relevance_is_active", "topic_relevance", ["is_active"]) | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| op.drop_table("topic_relevance") | ||
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
12 changes: 12 additions & 0 deletions
12
backend/app/api/docs/topic_relevance_configs/create_topic_relevance_config.md
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,12 @@ | ||
| Creates a topic relevance configuration for the tenant resolved from `X-API-KEY`. | ||
rkritika1508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Behavior notes: | ||
| - Stores a topic relevance preset with `name`, `prompt_version`, and `configuration`. | ||
rkritika1508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - `configuration` is a plain text scope sub-prompt (string). | ||
| - Tenant scope is enforced from the API key context. | ||
| - Duplicate configurations are rejected. | ||
|
|
||
| Common failure cases: | ||
| - Missing or invalid API key. | ||
| - Payload schema validation errors. | ||
| - Topic relevance with the same configuration already exists. | ||
8 changes: 8 additions & 0 deletions
8
backend/app/api/docs/topic_relevance_configs/delete_topic_relevance_config.md
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,8 @@ | ||
| Deletes a topic relevance configuration by id for the tenant resolved from `X-API-KEY`. | ||
|
|
||
| Behavior notes: | ||
| - Tenant scope is enforced from the API key context. | ||
|
|
||
| Common failure cases: | ||
| - Missing or invalid API key. | ||
| - Topic relevance preset not found in tenant's scope. |
9 changes: 9 additions & 0 deletions
9
backend/app/api/docs/topic_relevance_configs/get_topic_relevance_config.md
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,9 @@ | ||
| Fetches a single topic relevance configuration by id for the tenant resolved from `X-API-KEY`. | ||
|
|
||
| Behavior notes: | ||
| - Tenant scope is enforced from the API key context. | ||
|
|
||
| Common failure cases: | ||
| - Missing or invalid API key. | ||
| - Topic relevance preset not found in tenant's scope. | ||
| - Invalid id format. |
11 changes: 11 additions & 0 deletions
11
backend/app/api/docs/topic_relevance_configs/list_topic_relevance_configs.md
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 @@ | ||
| Lists topic relevance configurations for the tenant resolved from `X-API-KEY`. | ||
|
|
||
| Behavior notes: | ||
| - Supports pagination via `offset` and `limit`. | ||
| - `offset` defaults to `0`. | ||
| - `limit` is optional; when omitted, no limit is applied. | ||
| - Tenant scope is enforced from the API key context. | ||
|
|
||
| Common failure cases: | ||
| - Missing or invalid API key. | ||
| - Invalid pagination values. |
13 changes: 13 additions & 0 deletions
13
backend/app/api/docs/topic_relevance_configs/update_topic_relevance_config.md
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,13 @@ | ||
| Partially updates a topic relevance configuration by id for the tenant resolved from `X-API-KEY`. | ||
|
|
||
| Behavior notes: | ||
| - Supports patch-style updates; omitted fields remain unchanged. | ||
| - `configuration` should be provided as a plain text scope sub-prompt (string). | ||
| - Tenant scope is enforced from the API key context. | ||
| - Duplicate configurations are rejected. | ||
|
|
||
| Common failure cases: | ||
| - Missing or invalid API key. | ||
| - Topic relevance preset not found in tenant's scope. | ||
| - Payload schema validation errors. | ||
| - Topic relevance with the same configuration already exists. |
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.
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.