Skip to content

Commit 5593681

Browse files
committed
init
1 parent ac60cae commit 5593681

File tree

135 files changed

+34562
-4725
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+34562
-4725
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,13 @@ node_modules/
44
/playwright-report/
55
/blob-report/
66
/playwright/.cache/
7+
scripts/
8+
.env
9+
.env.local
10+
.env.development.local
11+
.env.test.local
12+
.env.production.local
13+
.env.development
14+
.env.test
15+
.env.production
16+
.DS_Store

backend/Dockerfile

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,33 @@
1-
FROM python:3.10
1+
FROM python:3.10 as dev
22

33
ENV PYTHONUNBUFFERED=1
44

55
WORKDIR /app/
66

7-
# Install uv
8-
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#installing-uv
9-
COPY --from=ghcr.io/astral-sh/uv:0.5.11 /uv /uvx /bin/
7+
# Install build dependencies
8+
RUN apt-get update && apt-get install -y \
9+
build-essential \
10+
curl \
11+
libpq-dev \
12+
python3-dev \
13+
&& rm -rf /var/lib/apt/lists/*
1014

11-
# Place executables in the environment at the front of the path
12-
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#using-the-environment
13-
ENV PATH="/app/.venv/bin:$PATH"
15+
# Copy dependency files
16+
COPY ./pyproject.toml ./alembic.ini /app/
1417

15-
# Compile bytecode
16-
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#compiling-bytecode
17-
ENV UV_COMPILE_BYTECODE=1
18-
19-
# uv Cache
20-
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#caching
21-
ENV UV_LINK_MODE=copy
22-
23-
# Install dependencies
24-
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
25-
RUN --mount=type=cache,target=/root/.cache/uv \
26-
--mount=type=bind,source=uv.lock,target=uv.lock \
27-
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
28-
uv sync --frozen --no-install-project
29-
30-
ENV PYTHONPATH=/app
18+
# Install pip and build tools
19+
RUN pip install --no-cache-dir pip setuptools wheel hatchling
3120

21+
# Copy application code
22+
COPY ./app /app/app
3223
COPY ./scripts /app/scripts
3324

34-
COPY ./pyproject.toml ./uv.lock ./alembic.ini /app/
25+
# Install the package and its dependencies
26+
RUN pip install --no-cache-dir .
3527

36-
COPY ./app /app/app
28+
ENV PYTHONPATH=/app
3729

38-
# Sync the project
39-
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
40-
RUN --mount=type=cache,target=/root/.cache/uv \
41-
uv sync
30+
# Make scripts executable
31+
RUN chmod +x /app/scripts/prestart.sh
4232

43-
CMD ["fastapi", "run", "--workers", "4", "app/main.py"]
33+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
"""remove_sharing_tables
2+
3+
Revision ID: 002_remove_sharing_tables
4+
Revises: 8cf5c34c4462
5+
Create Date: 2024-03-19 10:00:00.000000
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
from sqlalchemy.dialects import postgresql
11+
12+
# revision identifiers, used by Alembic.
13+
revision = '002_remove_sharing_tables'
14+
down_revision = '8cf5c34c4462'
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# Drop sharing-related tables
21+
op.drop_table('sharedchatmessage')
22+
op.drop_table('sharedchatsession')
23+
op.drop_table('aisoulentityshare')
24+
25+
26+
def downgrade():
27+
# Recreate sharing tables
28+
op.create_table(
29+
'aisoulentityshare',
30+
sa.Column('id', postgresql.UUID(), nullable=False),
31+
sa.Column('name', sa.String(length=255), nullable=False),
32+
sa.Column('description', sa.String(length=1000), nullable=True),
33+
sa.Column('is_public', sa.Boolean(), nullable=False),
34+
sa.Column('allow_anonymous', sa.Boolean(), nullable=False),
35+
sa.Column('share_code', sa.String(length=50), nullable=False),
36+
sa.Column('owner_id', postgresql.UUID(), nullable=False),
37+
sa.Column('ai_soul_id', postgresql.UUID(), nullable=False),
38+
sa.Column('created_at', sa.DateTime(), nullable=False),
39+
sa.Column('updated_at', sa.DateTime(), nullable=False),
40+
sa.Column('access_count', sa.Integer(), nullable=False),
41+
sa.Column('last_accessed', sa.DateTime(), nullable=True),
42+
sa.Column('is_active', sa.Boolean(), nullable=False),
43+
sa.ForeignKeyConstraint(['owner_id'], ['user.id'], ondelete='CASCADE'),
44+
sa.ForeignKeyConstraint(['ai_soul_id'], ['aisoulentity.id'], ondelete='CASCADE'),
45+
sa.PrimaryKeyConstraint('id'),
46+
sa.UniqueConstraint('share_code')
47+
)
48+
49+
op.create_table(
50+
'sharedchatsession',
51+
sa.Column('id', postgresql.UUID(), nullable=False),
52+
sa.Column('session_name', sa.String(length=255), nullable=True),
53+
sa.Column('share_id', postgresql.UUID(), nullable=False),
54+
sa.Column('visitor_identifier', sa.String(length=255), nullable=False),
55+
sa.Column('created_at', sa.DateTime(), nullable=False),
56+
sa.Column('last_message_at', sa.DateTime(), nullable=False),
57+
sa.Column('message_count', sa.Integer(), nullable=False),
58+
sa.Column('is_active', sa.Boolean(), nullable=False),
59+
sa.ForeignKeyConstraint(['share_id'], ['aisoulentityshare.id'], ondelete='CASCADE'),
60+
sa.PrimaryKeyConstraint('id')
61+
)
62+
63+
op.create_table(
64+
'sharedchatmessage',
65+
sa.Column('id', postgresql.UUID(), nullable=False),
66+
sa.Column('session_id', postgresql.UUID(), nullable=False),
67+
sa.Column('content', sa.String(length=5000), nullable=False),
68+
sa.Column('is_from_visitor', sa.Boolean(), nullable=False),
69+
sa.Column('timestamp', sa.DateTime(), nullable=False),
70+
sa.ForeignKeyConstraint(['session_id'], ['sharedchatsession.id'], ondelete='CASCADE'),
71+
sa.PrimaryKeyConstraint('id')
72+
)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"""increase_embedding_field_size
2+
3+
Revision ID: 26ef24513797
4+
Revises: 002_remove_sharing_tables
5+
Create Date: 2025-07-07 16:47:51.022514
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
import sqlmodel.sql.sqltypes
11+
12+
13+
# revision identifiers, used by Alembic.
14+
revision = '26ef24513797'
15+
down_revision = '002_remove_sharing_tables'
16+
branch_labels = None
17+
depends_on = None
18+
19+
20+
def upgrade():
21+
# ### commands auto generated by Alembic - please adjust! ###
22+
op.alter_column('documentchunk', 'embedding',
23+
existing_type=sa.VARCHAR(length=10000),
24+
type_=sqlmodel.sql.sqltypes.AutoString(length=50000),
25+
existing_nullable=True)
26+
op.alter_column('trainingdocumentchunk', 'embedding',
27+
existing_type=sa.VARCHAR(length=10000),
28+
type_=sqlmodel.sql.sqltypes.AutoString(length=50000),
29+
existing_nullable=True)
30+
op.alter_column('trainingmessage', 'embedding',
31+
existing_type=sa.VARCHAR(length=10000),
32+
type_=sqlmodel.sql.sqltypes.AutoString(length=50000),
33+
existing_nullable=True)
34+
# ### end Alembic commands ###
35+
36+
37+
def downgrade():
38+
# ### commands auto generated by Alembic - please adjust! ###
39+
op.alter_column('trainingmessage', 'embedding',
40+
existing_type=sqlmodel.sql.sqltypes.AutoString(length=50000),
41+
type_=sa.VARCHAR(length=10000),
42+
existing_nullable=True)
43+
op.alter_column('trainingdocumentchunk', 'embedding',
44+
existing_type=sqlmodel.sql.sqltypes.AutoString(length=50000),
45+
type_=sa.VARCHAR(length=10000),
46+
existing_nullable=True)
47+
op.alter_column('documentchunk', 'embedding',
48+
existing_type=sqlmodel.sql.sqltypes.AutoString(length=50000),
49+
type_=sa.VARCHAR(length=10000),
50+
existing_nullable=True)
51+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)