From b2e9d4bbfc14603710447d64831379ad4ec8c2c7 Mon Sep 17 00:00:00 2001 From: jnjpng Date: Fri, 9 May 2025 14:07:41 -0700 Subject: [PATCH] feat: add instructions field to sources (#2089) --- ...09530_add_instructions_field_to_sources.py | 31 +++++++++++++++++++ letta/orm/source.py | 1 + letta/schemas/source.py | 3 ++ 3 files changed, 35 insertions(+) create mode 100644 alembic/versions/18e300709530_add_instructions_field_to_sources.py diff --git a/alembic/versions/18e300709530_add_instructions_field_to_sources.py b/alembic/versions/18e300709530_add_instructions_field_to_sources.py new file mode 100644 index 00000000..138494d0 --- /dev/null +++ b/alembic/versions/18e300709530_add_instructions_field_to_sources.py @@ -0,0 +1,31 @@ +"""add instructions field to sources + +Revision ID: 18e300709530 +Revises: 878607e41ca4 +Create Date: 2025-05-08 17:56:20.877183 + +""" + +from typing import Sequence, Union + +import sqlalchemy as sa + +from alembic import op + +# revision identifiers, used by Alembic. +revision: str = "18e300709530" +down_revision: Union[str, None] = "878607e41ca4" +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("sources", sa.Column("instructions", sa.String(), nullable=True)) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column("sources", "instructions") + # ### end Alembic commands ### diff --git a/letta/orm/source.py b/letta/orm/source.py index b71e3989..9423bdaf 100644 --- a/letta/orm/source.py +++ b/letta/orm/source.py @@ -30,6 +30,7 @@ class Source(SqlalchemyBase, OrganizationMixin): name: Mapped[str] = mapped_column(doc="the name of the source, must be unique within the org", nullable=False) description: Mapped[str] = mapped_column(nullable=True, doc="a human-readable description of the source") + instructions: Mapped[str] = mapped_column(nullable=True, doc="instructions for how to use the source") embedding_config: Mapped[EmbeddingConfig] = mapped_column(EmbeddingConfigColumn, doc="Configuration settings for embedding.") metadata_: Mapped[Optional[dict]] = mapped_column(JSON, nullable=True, doc="metadata for the source.") diff --git a/letta/schemas/source.py b/letta/schemas/source.py index 46e04151..79476780 100644 --- a/letta/schemas/source.py +++ b/letta/schemas/source.py @@ -31,6 +31,7 @@ class Source(BaseSource): id: str = BaseSource.generate_id_field() name: str = Field(..., description="The name of the source.") description: Optional[str] = Field(None, description="The description of the source.") + instructions: Optional[str] = Field(None, description="Instructions for how to use the source.") embedding_config: EmbeddingConfig = Field(..., description="The embedding configuration used by the source.") organization_id: Optional[str] = Field(None, description="The ID of the organization that created the source.") metadata: Optional[dict] = Field(None, validation_alias="metadata_", description="Metadata associated with the source.") @@ -59,6 +60,7 @@ class SourceCreate(BaseSource): # optional description: Optional[str] = Field(None, description="The description of the source.") + instructions: Optional[str] = Field(None, description="Instructions for how to use the source.") metadata: Optional[dict] = Field(None, description="Metadata associated with the source.") @@ -69,5 +71,6 @@ class SourceUpdate(BaseSource): name: Optional[str] = Field(None, description="The name of the source.") description: Optional[str] = Field(None, description="The description of the source.") + instructions: Optional[str] = Field(None, description="Instructions for how to use the source.") metadata: Optional[dict] = Field(None, description="Metadata associated with the source.") embedding_config: Optional[EmbeddingConfig] = Field(None, description="The embedding configuration used by the source.")