-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use init_chat_model() helper method to initialise models (#87)
* Upgrade langchain version to 0.2.8 * Use new init_chat_model function to initialise any models. Remove models.py since its redundant * Add migration file to convert all provider names in member table to new name format * Update default provider and model names when creating new member * Update frontend available model provider names * Update test_members to use new provider name
- Loading branch information
1 parent
890b4b4
commit 9409207
Showing
8 changed files
with
64 additions
and
40 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
backend/app/alembic/versions/6e7c33ddf30f_rename_provider_names_in_members_table_.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,40 @@ | ||
"""Rename provider names in member table to new name | ||
Revision ID: 6e7c33ddf30f | ||
Revises: 0a354b5c6f6c | ||
Create Date: 2024-07-27 04:29:51.886906 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '6e7c33ddf30f' | ||
down_revision = '0a354b5c6f6c' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# Mapping of old provider names to new provider names | ||
mapping = { | ||
'ChatOpenAI': 'openai', | ||
'ChatAnthropic': 'anthropic', | ||
} | ||
|
||
# Rename each provider name according to the mapping | ||
for old_name, new_name in mapping.items(): | ||
op.execute(f"UPDATE member SET provider = '{new_name}' WHERE provider = '{old_name}'") | ||
|
||
|
||
def downgrade(): | ||
# Mapping of new provider names back to old provider names | ||
mapping = { | ||
'openai': 'ChatOpenAI', | ||
'anthropic': 'ChatAnthropic', | ||
} | ||
|
||
# Revert each provider name according to the mapping | ||
for new_name, old_name in mapping.items(): | ||
op.execute(f"UPDATE member SET provider = '{old_name}' WHERE provider = '{new_name}'") |
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 was deleted.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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