-
Notifications
You must be signed in to change notification settings - Fork 659
fix(migrations): dynamic embedding dimenstions #770
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -363,7 +363,7 @@ def upgrade() -> None: | |
| server_default="{}", | ||
| ), | ||
| sa.Column("content", sa.Text(), nullable=False), | ||
| sa.Column("embedding", Vector(1536), nullable=True), # pyright: ignore | ||
| sa.Column("embedding", Vector(settings.EMBEDDING.VECTOR_DIMENSIONS), nullable=True), # pyright: ignore | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Configuration-driven migrations break reproducibility. Alembic migrations should be immutable historical records. Reading
If you need to support multiple vector dimensions, consider:
🤖 Prompt for AI Agents |
||
| sa.Column( | ||
| "created_at", | ||
| sa.DateTime(timezone=True), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ | |
|
|
||
| # OpenAI-compatible models that reject the `dimensions=` request parameter. | ||
| _EMBEDDING_KNOWN_REJECTING_MODELS: frozenset[str] = frozenset( | ||
| {"text-embedding-ada-002"} | ||
| {"text-embedding-ada-002", "mistral-embed"} | ||
| ) | ||
|
Comment on lines
30
to
32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: Mistral’s embeddings API supports an Citations:
Adjust Mistral embedding “dimensions” handling for
🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
existing_typemismatch risk if config differs from deployed schema.The
existing_typeparameter tells Alembic the current column type. Ifsettings.EMBEDDING.VECTOR_DIMENSIONSdoesn't match the dimension actually in the database (e.g., the initial migration ran with a different config value), this could cause:existing_typefor ALTER statementsSince this migration only changes
nullable, PostgreSQL typically handles this correctly regardless ofexisting_type, but the mismatch creates fragility. Consider hardcoding the expected dimension or validating it matches the database at runtime.🤖 Prompt for AI Agents