-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* clean horizontal scrollbar * provider fix * ensure proper migration * k * update migration * Revert "clean horizontal scrollbar" This reverts commit fa592a1.
- Loading branch information
Showing
3 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
backend/alembic/versions/177de57c21c9_display_custom_llm_models.py
This file contains 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,59 @@ | ||
"""display custom llm models | ||
Revision ID: 177de57c21c9 | ||
Revises: 4ee1287bd26a | ||
Create Date: 2024-11-21 11:49:04.488677 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
from sqlalchemy import and_ | ||
|
||
revision = "177de57c21c9" | ||
down_revision = "4ee1287bd26a" | ||
branch_labels = None | ||
depends_on = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
conn = op.get_bind() | ||
llm_provider = sa.table( | ||
"llm_provider", | ||
sa.column("id", sa.Integer), | ||
sa.column("provider", sa.String), | ||
sa.column("model_names", postgresql.ARRAY(sa.String)), | ||
sa.column("display_model_names", postgresql.ARRAY(sa.String)), | ||
) | ||
|
||
excluded_providers = ["openai", "bedrock", "anthropic", "azure"] | ||
|
||
providers_to_update = sa.select( | ||
llm_provider.c.id, | ||
llm_provider.c.model_names, | ||
llm_provider.c.display_model_names, | ||
).where( | ||
and_( | ||
~llm_provider.c.provider.in_(excluded_providers), | ||
llm_provider.c.model_names.isnot(None), | ||
) | ||
) | ||
|
||
results = conn.execute(providers_to_update).fetchall() | ||
|
||
for provider_id, model_names, display_model_names in results: | ||
if display_model_names is None: | ||
display_model_names = [] | ||
|
||
combined_model_names = list(set(display_model_names + model_names)) | ||
update_stmt = ( | ||
llm_provider.update() | ||
.where(llm_provider.c.id == provider_id) | ||
.values(display_model_names=combined_model_names) | ||
) | ||
conn.execute(update_stmt) | ||
|
||
|
||
def downgrade() -> None: | ||
pass |
This file contains 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 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