feat(api): 接入智谱 embedding-3(1024 维)并迁移 memory_chunks 向量列
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
"""memory_chunks.embedding: vector(1536) -> vector(1024),并清空旧向量。
|
||||
|
||||
与智谱 embedding-3(固定 1024 维)及 ORM 一致;旧 OpenAI 等模型向量不可与智谱混用,故先置 NULL 再改类型。
|
||||
|
||||
Revision ID: 0004_memory_embedding_1024
|
||||
Revises: 0003_timeline_memory_source
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from alembic import op
|
||||
|
||||
revision: str = "0004_memory_embedding_1024"
|
||||
down_revision: Union[str, None] = "0003_timeline_memory_source"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.execute(sa.text("UPDATE memory_chunks SET embedding = NULL"))
|
||||
op.execute(
|
||||
sa.text("ALTER TABLE memory_chunks ALTER COLUMN embedding TYPE vector(1024)")
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.execute(sa.text("UPDATE memory_chunks SET embedding = NULL"))
|
||||
op.execute(
|
||||
sa.text("ALTER TABLE memory_chunks ALTER COLUMN embedding TYPE vector(1536)")
|
||||
)
|
||||
Reference in New Issue
Block a user