Skip to content

DENISTEK AI Counseling Platform #1714

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@ node_modules/
/playwright-report/
/blob-report/
/playwright/.cache/
scripts/
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
.env.development
.env.test
.env.production
.DS_Store
50 changes: 20 additions & 30 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,43 +1,33 @@
FROM python:3.10
FROM python:3.10 as dev

ENV PYTHONUNBUFFERED=1

WORKDIR /app/

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

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

# Compile bytecode
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#compiling-bytecode
ENV UV_COMPILE_BYTECODE=1

# uv Cache
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#caching
ENV UV_LINK_MODE=copy

# Install dependencies
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project

ENV PYTHONPATH=/app
# Install pip and build tools
RUN pip install --no-cache-dir pip setuptools wheel hatchling

# Copy application code
COPY ./app /app/app
COPY ./scripts /app/scripts

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

COPY ./app /app/app
ENV PYTHONPATH=/app

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

CMD ["fastapi", "run", "--workers", "4", "app/main.py"]
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
72 changes: 72 additions & 0 deletions backend/app/alembic/versions/002_remove_sharing_tables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"""remove_sharing_tables

Revision ID: 002_remove_sharing_tables
Revises: 8cf5c34c4462
Create Date: 2024-03-19 10:00:00.000000

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '002_remove_sharing_tables'
down_revision = '8cf5c34c4462'
branch_labels = None
depends_on = None


def upgrade():
# Drop sharing-related tables
op.drop_table('sharedchatmessage')
op.drop_table('sharedchatsession')
op.drop_table('aisoulentityshare')


def downgrade():
# Recreate sharing tables
op.create_table(
'aisoulentityshare',
sa.Column('id', postgresql.UUID(), nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column('description', sa.String(length=1000), nullable=True),
sa.Column('is_public', sa.Boolean(), nullable=False),
sa.Column('allow_anonymous', sa.Boolean(), nullable=False),
sa.Column('share_code', sa.String(length=50), nullable=False),
sa.Column('owner_id', postgresql.UUID(), nullable=False),
sa.Column('ai_soul_id', postgresql.UUID(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.Column('updated_at', sa.DateTime(), nullable=False),
sa.Column('access_count', sa.Integer(), nullable=False),
sa.Column('last_accessed', sa.DateTime(), nullable=True),
sa.Column('is_active', sa.Boolean(), nullable=False),
sa.ForeignKeyConstraint(['owner_id'], ['user.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['ai_soul_id'], ['aisoulentity.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('share_code')
)

op.create_table(
'sharedchatsession',
sa.Column('id', postgresql.UUID(), nullable=False),
sa.Column('session_name', sa.String(length=255), nullable=True),
sa.Column('share_id', postgresql.UUID(), nullable=False),
sa.Column('visitor_identifier', sa.String(length=255), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.Column('last_message_at', sa.DateTime(), nullable=False),
sa.Column('message_count', sa.Integer(), nullable=False),
sa.Column('is_active', sa.Boolean(), nullable=False),
sa.ForeignKeyConstraint(['share_id'], ['aisoulentityshare.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id')
)

op.create_table(
'sharedchatmessage',
sa.Column('id', postgresql.UUID(), nullable=False),
sa.Column('session_id', postgresql.UUID(), nullable=False),
sa.Column('content', sa.String(length=5000), nullable=False),
sa.Column('is_from_visitor', sa.Boolean(), nullable=False),
sa.Column('timestamp', sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(['session_id'], ['sharedchatsession.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id')
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""increase_embedding_field_size

Revision ID: 26ef24513797
Revises: 002_remove_sharing_tables
Create Date: 2025-07-07 16:47:51.022514

"""
from alembic import op
import sqlalchemy as sa
import sqlmodel.sql.sqltypes


# revision identifiers, used by Alembic.
revision = '26ef24513797'
down_revision = '002_remove_sharing_tables'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('documentchunk', 'embedding',
existing_type=sa.VARCHAR(length=10000),
type_=sqlmodel.sql.sqltypes.AutoString(length=50000),
existing_nullable=True)
op.alter_column('trainingdocumentchunk', 'embedding',
existing_type=sa.VARCHAR(length=10000),
type_=sqlmodel.sql.sqltypes.AutoString(length=50000),
existing_nullable=True)
op.alter_column('trainingmessage', 'embedding',
existing_type=sa.VARCHAR(length=10000),
type_=sqlmodel.sql.sqltypes.AutoString(length=50000),
existing_nullable=True)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('trainingmessage', 'embedding',
existing_type=sqlmodel.sql.sqltypes.AutoString(length=50000),
type_=sa.VARCHAR(length=10000),
existing_nullable=True)
op.alter_column('trainingdocumentchunk', 'embedding',
existing_type=sqlmodel.sql.sqltypes.AutoString(length=50000),
type_=sa.VARCHAR(length=10000),
existing_nullable=True)
op.alter_column('documentchunk', 'embedding',
existing_type=sqlmodel.sql.sqltypes.AutoString(length=50000),
type_=sa.VARCHAR(length=10000),
existing_nullable=True)
# ### end Alembic commands ###
Loading
Loading