gevent concurrency / asynchronous processes
usage of gunicorn (documented)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
"""Embeddings for OpenAI
|
||||
|
||||
Revision ID: 4f22dd6260e3
|
||||
Revises: f5bbaed3a9ee
|
||||
Create Date: 2024-04-30 21:18:35.548528
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import pgvector
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '4f22dd6260e3'
|
||||
down_revision = 'f5bbaed3a9ee'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('embedding_small_open_ai',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('doc_vers_id', sa.Integer(), nullable=False),
|
||||
sa.Column('active', sa.Boolean(), nullable=False),
|
||||
sa.Column('embedding', pgvector.sqlalchemy.Vector(dim=1536), nullable=False),
|
||||
sa.ForeignKeyConstraint(['doc_vers_id'], ['document_version.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('embedding_small_open_ai')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,65 @@
|
||||
"""Initial Document Models added
|
||||
|
||||
Revision ID: 83b4a2aedbf1
|
||||
Revises:
|
||||
Create Date: 2024-04-24 14:39:05.302087
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '83b4a2aedbf1'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('document',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=100), nullable=False),
|
||||
sa.Column('tenant_id', sa.Integer(), nullable=False),
|
||||
sa.Column('valid_from', sa.DateTime(), nullable=True),
|
||||
sa.Column('valid_to', sa.DateTime(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('created_by', sa.Integer(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_by', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['created_by'], ['public.user.id'], ),
|
||||
sa.ForeignKeyConstraint(['tenant_id'], ['public.tenant.id'], ),
|
||||
sa.ForeignKeyConstraint(['updated_by'], ['public.user.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('document_language',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('document_id', sa.Integer(), nullable=False),
|
||||
sa.Column('language', sa.String(length=2), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('created_by', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['created_by'], ['public.user.id'], ),
|
||||
sa.ForeignKeyConstraint(['document_id'], ['document.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('document_version',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('doc_lang_id', sa.Integer(), nullable=False),
|
||||
sa.Column('url', sa.String(length=200), nullable=True),
|
||||
sa.Column('embeddings', sa.PickleType(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('created_by', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['created_by'], ['public.user.id'], ),
|
||||
sa.ForeignKeyConstraint(['doc_lang_id'], ['document_language.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('document_version')
|
||||
op.drop_table('document_language')
|
||||
op.drop_table('document')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,56 @@
|
||||
"""Embeddings according to pgvector decision
|
||||
|
||||
Revision ID: f5bbaed3a9ee
|
||||
Revises: 83b4a2aedbf1
|
||||
Create Date: 2024-04-30 10:57:48.310528
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
import pgvector
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'f5bbaed3a9ee'
|
||||
down_revision = '83b4a2aedbf1'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('embedding_mistral',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('doc_vers_id', sa.Integer(), nullable=False),
|
||||
sa.Column('active', sa.Boolean(), nullable=False),
|
||||
sa.Column('embedding', pgvector.sqlalchemy.Vector(dim=1024), nullable=False),
|
||||
sa.ForeignKeyConstraint(['doc_vers_id'], ['document_version.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.add_column('document_language', sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
|
||||
op.add_column('document_language', sa.Column('updated_by', sa.Integer(), nullable=True))
|
||||
op.create_foreign_key(None, 'document_language', 'user', ['updated_by'], ['id'], referent_schema='public')
|
||||
op.add_column('document_version', sa.Column('file_location', sa.String(length=255), nullable=True))
|
||||
op.add_column('document_version', sa.Column('file_name', sa.String(length=200), nullable=True))
|
||||
op.add_column('document_version', sa.Column('file_type', sa.String(length=20), nullable=True))
|
||||
op.add_column('document_version', sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
|
||||
op.add_column('document_version', sa.Column('updated_by', sa.Integer(), nullable=True))
|
||||
op.create_foreign_key(None, 'document_version', 'user', ['updated_by'], ['id'], referent_schema='public')
|
||||
op.drop_column('document_version', 'embeddings')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('document_version', sa.Column('embeddings', postgresql.BYTEA(), autoincrement=False, nullable=True))
|
||||
op.drop_constraint(None, 'document_version', type_='foreignkey')
|
||||
op.drop_column('document_version', 'updated_by')
|
||||
op.drop_column('document_version', 'updated_at')
|
||||
op.drop_column('document_version', 'file_type')
|
||||
op.drop_column('document_version', 'file_name')
|
||||
op.drop_column('document_version', 'file_location')
|
||||
op.drop_constraint(None, 'document_language', type_='foreignkey')
|
||||
op.drop_column('document_language', 'updated_by')
|
||||
op.drop_column('document_language', 'updated_at')
|
||||
op.drop_table('embedding_mistral')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user