From 4fb0fe28b7fb7458758fd9a03dab7734cccfa808 Mon Sep 17 00:00:00 2001 From: Matthew Zhou Date: Wed, 20 Aug 2025 13:33:31 -0700 Subject: [PATCH] fix: Fix letta-free embeddings (#4055) --- letta/schemas/embedding_config.py | 8 ++--- letta/schemas/providers/letta.py | 6 ++-- tests/integration_test_batch_api_cron_jobs.py | 6 ++-- tests/test_sources.py | 29 +++++++++++++++++++ 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/letta/schemas/embedding_config.py b/letta/schemas/embedding_config.py index bf89039d..2840146e 100644 --- a/letta/schemas/embedding_config.py +++ b/letta/schemas/embedding_config.py @@ -62,11 +62,11 @@ class EmbeddingConfig(BaseModel): ) elif model_name == "letta": return cls( - embedding_endpoint="https://bun-function-production-e310.up.railway.app/v1", - embedding_model="BAAI/bge-large-en-v1.5", - embedding_dim=1024, + embedding_endpoint="https://embeddings.letta.com/", + embedding_model="letta-free", + embedding_dim=1536, embedding_chunk_size=DEFAULT_EMBEDDING_CHUNK_SIZE, - embedding_endpoint_type="hugging-face", + embedding_endpoint_type="openai", ) elif provider == "pinecone": # default config for pinecone with empty endpoint diff --git a/letta/schemas/providers/letta.py b/letta/schemas/providers/letta.py index 707d4899..34151fac 100644 --- a/letta/schemas/providers/letta.py +++ b/letta/schemas/providers/letta.py @@ -30,9 +30,9 @@ class LettaProvider(Provider): return [ EmbeddingConfig( embedding_model="letta-free", # NOTE: renamed - embedding_endpoint_type="hugging-face", - embedding_endpoint="https://bun-function-production-e310.up.railway.app/v1", - embedding_dim=1024, + embedding_endpoint_type="openai", + embedding_endpoint="https://embeddings.letta.com/", + embedding_dim=1536, embedding_chunk_size=DEFAULT_EMBEDDING_CHUNK_SIZE, handle=self.get_handle("letta-free", is_embedding=True), ) diff --git a/tests/integration_test_batch_api_cron_jobs.py b/tests/integration_test_batch_api_cron_jobs.py index 08337f08..95d98bf2 100644 --- a/tests/integration_test_batch_api_cron_jobs.py +++ b/tests/integration_test_batch_api_cron_jobs.py @@ -148,9 +148,9 @@ def create_test_agent(name, actor, test_id: Optional[str] = None, model="anthrop dummy_embedding_config = EmbeddingConfig( embedding_model="letta-free", - embedding_endpoint_type="hugging-face", - embedding_endpoint="https://bun-function-production-e310.up.railway.app/v1", - embedding_dim=1024, + embedding_endpoint_type="openai", + embedding_endpoint="https://embeddings.letta.com/", + embedding_dim=1536, embedding_chunk_size=300, handle="letta/letta-free", ) diff --git a/tests/test_sources.py b/tests/test_sources.py index 9f96c01d..8dc235de 100644 --- a/tests/test_sources.py +++ b/tests/test_sources.py @@ -1284,3 +1284,32 @@ def test_file_processing_timeout_logic(): # Test recent file recent_time = current_time - timedelta(minutes=10) assert not (recent_time < timeout_threshold), "Recent file should not trigger timeout" + + +def test_letta_free_embedding(disable_pinecone, client: LettaSDKClient): + """Test creating a source with letta/letta-free embedding and uploading a file""" + # create a source with letta-free embedding + source = client.sources.create(name="test_letta_free_source", embedding="letta/letta-free") + + # verify source was created with correct embedding + assert source.name == "test_letta_free_source" + print("\n\n\n\ntest") + print(source.embedding_config) + # assert source.embedding_config.embedding_model == "letta-free" + + # upload test.txt file + file_path = "tests/data/test.txt" + file_metadata = upload_file_and_wait(client, source.id, file_path) + + # verify file was uploaded successfully + assert file_metadata.processing_status == "completed" + assert file_metadata.source_id == source.id + assert file_metadata.file_name == "test.txt" + + # verify file appears in source files list + files = client.sources.files.list(source_id=source.id, limit=1) + assert len(files) == 1 + assert files[0].id == file_metadata.id + + # cleanup + client.sources.delete(source_id=source.id)