Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

feat: deprecate `EmbeddingConfig` from archives (#6038)

Sarah Woodersff87673963fd
diff --git a/fern/openapi.json b/fern/openapi.json
index ea050f4a7..12c212209 100644
--- a/fern/openapi.json
+++ b/fern/openapi.json
@@ -20118,8 +20118,28 @@
"title": "Name"
},
"embedding_config": {
- "$ref": "#/components/schemas/EmbeddingConfig",
- "description": "Embedding configuration for the archive"
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/EmbeddingConfig"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Deprecated: Use `embedding` field instead. Embedding configuration for the archive",
+ "deprecated": true
+ },
+ "embedding": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Embedding",
+ "description": "Embedding model handle for the archive"
},
"description": {
"anyOf": [
@@ -20134,7 +20154,7 @@
}
},
"type": "object",
- "required": ["name", "embedding_config"],
+ "required": ["name"],
"title": "ArchiveCreateRequest",
"description": "Request model for creating an archive.\n\nIntentionally excludes vector_db_provider. These are derived internally (vector DB provider from env)."
},
@@ -28566,7 +28586,7 @@
"type": "object",
"required": ["model", "model_endpoint_type", "context_window"],
"title": "LLMConfig",
- "description": "Configuration for Language Model (LLM) connection and generation parameters."
+ "description": "Configuration for Language Model (LLM) connection and generation parameters.\n\n.. deprecated::\n LLMConfig is deprecated and should not be used as an input or return type in API calls.\n Use the schemas in letta.schemas.model (ModelSettings, OpenAIModelSettings, etc.) instead.\n For conversion, use the _to_model() method or Model._from_llm_config() method."
},
"LettaAsyncRequest": {
"properties": {
diff --git a/letta/schemas/llm_config.py b/letta/schemas/llm_config.py
index 3c1c95fe5..a0e59c8ba 100644
--- a/letta/schemas/llm_config.py
+++ b/letta/schemas/llm_config.py
@@ -14,7 +14,13 @@ logger = get_logger(__name__)
class LLMConfig(BaseModel):
- """Configuration for Language Model (LLM) connection and generation parameters."""
+ """Configuration for Language Model (LLM) connection and generation parameters.
+
+ .. deprecated::
+ LLMConfig is deprecated and should not be used as an input or return type in API calls.
+ Use the schemas in letta.schemas.model (ModelSettings, OpenAIModelSettings, etc.) instead.
+ For conversion, use the _to_model() method or Model._from_llm_config() method.
+ """
model: str = Field(..., description="LLM model name. ")
display_name: Optional[str] = Field(None, description="A human-friendly display name for the model.")
diff --git a/letta/server/rest_api/routers/v1/archives.py b/letta/server/rest_api/routers/v1/archives.py
index 6357b49fa..4e0a67d69 100644
--- a/letta/server/rest_api/routers/v1/archives.py
+++ b/letta/server/rest_api/routers/v1/archives.py
@@ -5,6 +5,7 @@ from fastapi import APIRouter, Body, Depends, Query
from pydantic import BaseModel, Field
from letta import AgentState
+from letta.errors import LettaInvalidArgumentError
from letta.schemas.agent import AgentRelationships
from letta.schemas.archive import Archive as PydanticArchive, ArchiveBase
from letta.schemas.embedding_config import EmbeddingConfig
@@ -23,7 +24,10 @@ class ArchiveCreateRequest(BaseModel):
"""
name: str
- embedding_config: EmbeddingConfig = Field(..., description="Embedding configuration for the archive")
+ embedding_config: Optional[EmbeddingConfig] = Field(
+ None, description="Deprecated: Use `embedding` field instead. Embedding configuration for the archive", deprecated=True
+ )
+ embedding: Optional[str] = Field(None, description="Embedding model handle for the archive")
description: Optional[str] = None
@@ -55,9 +59,21 @@ async def create_archive(
Create a new archive.
"""
actor = await server.user_manager.get_actor_or_default_async(actor_id=headers.actor_id)
+
+ if archive.embedding_config is None and archive.embedding is None:
+ raise LettaInvalidArgumentError("Either embedding_config or embedding must be provided")
+
+ embedding_config = archive.embedding_config
+ if embedding_config is None and archive.embedding is not None:
+ handle = f"{archive.embedding.provider}/{archive.embedding.model}"
+ embedding_config = await server.get_embedding_config_from_handle_async(
+ handle=handle,
+ actor=actor,
+ )
+
return await server.archive_manager.create_archive_async(
name=archive.name,
- embedding_config=archive.embedding_config,
+ embedding_config=embedding_config,
description=archive.description,
actor=actor,
)