-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
100 changed files
with
3,293 additions
and
8,699 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
chatui | ||
**/__pycache__ | ||
**/.pytest_cache | ||
**/*.pyc | ||
**/*.pyo | ||
**/*.pyd | ||
.git | ||
.gitignore | ||
.env | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Check Poetry Dependencies Changes | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- 'poetry.lock' | ||
- 'pyproject.toml' | ||
|
||
jobs: | ||
check-poetry-changes: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Check for poetry.lock changes | ||
id: check-poetry-lock | ||
run: | | ||
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep -q "poetry.lock"; then | ||
echo "poetry_lock_changed=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "poetry_lock_changed=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Check for pyproject.toml changes | ||
id: check-pyproject | ||
run: | | ||
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep -q "pyproject.toml"; then | ||
echo "pyproject_changed=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "pyproject_changed=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Create PR comment | ||
if: steps.check-poetry-lock.outputs.poetry_lock_changed == 'true' || steps.check-pyproject.outputs.pyproject_changed == 'true' | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const poetryLockChanged = ${{ steps.check-poetry-lock.outputs.poetry_lock_changed }}; | ||
const pyprojectChanged = ${{ steps.check-pyproject.outputs.pyproject_changed }}; | ||
let message = '📦 Dependencies Alert:\n\n'; | ||
if (poetryLockChanged && pyprojectChanged) { | ||
message += '- Both `poetry.lock` and `pyproject.toml` have been modified\n'; | ||
} else if (poetryLockChanged) { | ||
message += '- `poetry.lock` has been modified\n'; | ||
} else if (pyprojectChanged) { | ||
message += '- `pyproject.toml` has been modified\n'; | ||
} | ||
message += '\nPlease review these changes carefully to ensure they are intended (cc @sarahwooders @cpacker).'; | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: message | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,69 @@ | ||
# The builder image, used to build the virtual environment | ||
FROM python:3.12.2-bookworm as builder | ||
ARG LETTA_ENVIRONMENT=PRODUCTION | ||
ENV LETTA_ENVIRONMENT=${LETTA_ENVIRONMENT} | ||
RUN pip install poetry==1.8.2 | ||
# Start with pgvector base for builder | ||
FROM ankane/pgvector:v0.5.1 AS builder | ||
|
||
# Install Python and required packages | ||
RUN apt-get update && apt-get install -y \ | ||
python3 \ | ||
python3-venv \ | ||
python3-pip \ | ||
python3-full \ | ||
build-essential \ | ||
libpq-dev \ | ||
python3-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ENV POETRY_NO_INTERACTION=1 \ | ||
ARG LETTA_ENVIRONMENT=PRODUCTION | ||
ENV LETTA_ENVIRONMENT=${LETTA_ENVIRONMENT} \ | ||
POETRY_NO_INTERACTION=1 \ | ||
POETRY_VIRTUALENVS_IN_PROJECT=1 \ | ||
POETRY_VIRTUALENVS_CREATE=1 \ | ||
POETRY_CACHE_DIR=/tmp/poetry_cache | ||
|
||
WORKDIR /app | ||
|
||
# Create and activate virtual environment | ||
RUN python3 -m venv /opt/venv | ||
ENV PATH="/opt/venv/bin:$PATH" | ||
|
||
# Now install poetry in the virtual environment | ||
RUN pip install --no-cache-dir poetry==1.8.2 | ||
|
||
# Copy dependency files first | ||
COPY pyproject.toml poetry.lock ./ | ||
RUN poetry lock --no-update | ||
RUN if [ "$LETTA_ENVIRONMENT" = "DEVELOPMENT" ] ; then \ | ||
poetry install --no-root -E "postgres server dev" ; \ | ||
else \ | ||
poetry install --no-root --all-extras && \ | ||
rm -rf $POETRY_CACHE_DIR ; \ | ||
fi | ||
# Then copy the rest of the application code | ||
COPY . . | ||
|
||
RUN poetry lock --no-update && \ | ||
poetry install --all-extras && \ | ||
rm -rf $POETRY_CACHE_DIR | ||
|
||
# Runtime stage | ||
FROM ankane/pgvector:v0.5.1 AS runtime | ||
|
||
# Install Python packages | ||
RUN apt-get update && apt-get install -y \ | ||
python3 \ | ||
python3-venv \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& mkdir -p /app | ||
|
||
# The runtime image, used to just run the code provided its virtual environment | ||
FROM python:3.12.2-slim-bookworm as runtime | ||
ARG LETTA_ENVIRONMENT=PRODUCTION | ||
ENV LETTA_ENVIRONMENT=${LETTA_ENVIRONMENT} | ||
ENV VIRTUAL_ENV=/app/.venv \ | ||
PATH="/app/.venv/bin:$PATH" | ||
ENV LETTA_ENVIRONMENT=${LETTA_ENVIRONMENT} \ | ||
VIRTUAL_ENV="/app/.venv" \ | ||
PATH="/app/.venv/bin:$PATH" \ | ||
POSTGRES_USER=letta \ | ||
POSTGRES_PASSWORD=letta \ | ||
POSTGRES_DB=letta | ||
|
||
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV} | ||
WORKDIR /app | ||
|
||
COPY ./letta /letta | ||
COPY ./alembic.ini /alembic.ini | ||
COPY ./alembic /alembic | ||
# Copy virtual environment and app from builder | ||
COPY --from=builder /app . | ||
|
||
EXPOSE 8283 | ||
# Copy initialization SQL if it exists | ||
COPY init.sql /docker-entrypoint-initdb.d/ | ||
|
||
CMD ./letta/server/startup.sh | ||
EXPOSE 8283 5432 | ||
|
||
# allow for in-container development and testing | ||
FROM builder as development | ||
ARG LETTA_ENVIRONMENT=PRODUCTION | ||
ENV LETTA_ENVIRONMENT=${LETTA_ENVIRONMENT} | ||
ENV VIRTUAL_ENV=/app/.venv \ | ||
PATH="/app/.venv/bin:$PATH" | ||
ENV PYTHONPATH=/ | ||
WORKDIR / | ||
COPY ./tests /tests | ||
COPY ./letta /letta | ||
COPY ./alembic.ini /alembic.ini | ||
COPY ./alembic /alembic | ||
#COPY ./configs/server_config.yaml /root/.letta/config | ||
EXPOSE 8083 | ||
|
||
CMD ./letta/server/startup.sh | ||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] | ||
CMD ["./letta/server/startup.sh"] |
63 changes: 63 additions & 0 deletions
63
alembic/versions/95badb46fdf9_migrate_messages_to_the_orm.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
"""Migrate message to orm | ||
Revision ID: 95badb46fdf9 | ||
Revises: 3c683a662c82 | ||
Create Date: 2024-12-05 14:02:04.163150 | ||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "95badb46fdf9" | ||
down_revision: Union[str, None] = "08b2f8225812" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column("messages", sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=True)) | ||
op.add_column("messages", sa.Column("is_deleted", sa.Boolean(), server_default=sa.text("FALSE"), nullable=False)) | ||
op.add_column("messages", sa.Column("_created_by_id", sa.String(), nullable=True)) | ||
op.add_column("messages", sa.Column("_last_updated_by_id", sa.String(), nullable=True)) | ||
op.add_column("messages", sa.Column("organization_id", sa.String(), nullable=True)) | ||
# Populate `organization_id` based on `user_id` | ||
# Use a raw SQL query to update the organization_id | ||
op.execute( | ||
""" | ||
UPDATE messages | ||
SET organization_id = users.organization_id | ||
FROM users | ||
WHERE messages.user_id = users.id | ||
""" | ||
) | ||
op.alter_column("messages", "organization_id", nullable=False) | ||
op.alter_column("messages", "tool_calls", existing_type=postgresql.JSON(astext_type=sa.Text()), nullable=False) | ||
op.alter_column("messages", "created_at", existing_type=postgresql.TIMESTAMP(timezone=True), nullable=False) | ||
op.drop_index("message_idx_user", table_name="messages") | ||
op.create_foreign_key(None, "messages", "agents", ["agent_id"], ["id"]) | ||
op.create_foreign_key(None, "messages", "organizations", ["organization_id"], ["id"]) | ||
op.drop_column("messages", "user_id") | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column("messages", sa.Column("user_id", sa.VARCHAR(), autoincrement=False, nullable=False)) | ||
op.drop_constraint(None, "messages", type_="foreignkey") | ||
op.drop_constraint(None, "messages", type_="foreignkey") | ||
op.create_index("message_idx_user", "messages", ["user_id", "agent_id"], unique=False) | ||
op.alter_column("messages", "created_at", existing_type=postgresql.TIMESTAMP(timezone=True), nullable=True) | ||
op.alter_column("messages", "tool_calls", existing_type=postgresql.JSON(astext_type=sa.Text()), nullable=True) | ||
op.drop_column("messages", "organization_id") | ||
op.drop_column("messages", "_last_updated_by_id") | ||
op.drop_column("messages", "_created_by_id") | ||
op.drop_column("messages", "is_deleted") | ||
op.drop_column("messages", "updated_at") | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
alembic/versions/a91994b9752f_add_column_to_tools_table_to_contain_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"""add column to tools table to contain function return limit return_char_limit | ||
Revision ID: a91994b9752f | ||
Revises: e1a625072dbf | ||
Create Date: 2024-12-09 18:27:25.650079 | ||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
import sqlalchemy as sa | ||
|
||
from alembic import op | ||
from letta.constants import FUNCTION_RETURN_CHAR_LIMIT | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "a91994b9752f" | ||
down_revision: Union[str, None] = "e1a625072dbf" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column("tools", sa.Column("return_char_limit", sa.Integer(), nullable=True)) | ||
|
||
# Populate `return_char_limit` column | ||
op.execute( | ||
f""" | ||
UPDATE tools | ||
SET return_char_limit = {FUNCTION_RETURN_CHAR_LIMIT} | ||
""" | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column("tools", "return_char_limit") | ||
# ### end Alembic commands ### |
Oops, something went wrong.