letta-ai / letta

Letta (formerly MemGPT) is a framework for creating LLM services with memory.
https://letta.com
Apache License 2.0
12.67k stars 1.38k forks source link

Error "Input should be a valid string" sending request to API #1408

Open gcalabria opened 5 months ago

gcalabria commented 5 months ago

Describe the bug

When I send a request to the API endpoint /api/agents/${agent_id}/config I get the following error:

 File "/Users/gui/wild/ai-prototypes-long-term-memory/MemGPT/memgpt/server/rest_api/agents/config.py", line 92, in get_agent_config
    return GetAgentResponse(
           ^^^^^^^^^^^^^^^^^
  File "/Users/gui/.pyenv/versions/3.11.9/envs/ai-prototype-long-term-memory/lib/python3.11/site-packages/pydantic/main.py", line 176, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for GetAgentResponse
sources.0
  Input should be a valid string [type=string_type, input_value=UUID('8194051a-3ce9-4bea-9ee9-9581abc1b793'), input_type=UUID]
    For further information visit https://errors.pydantic.dev/2.7/v/string_type

I took a look and the attached_sources variable is a list of UUIDs but the GetAgentResponse expects a list of strings instead. The question is: should we change the GetAgentResponse pydantic model or simply convert the UUIDs to strings?

Please describe your setup

Additional context The problem only happens after I attach a data source to an agent.

MemGPT Config

[defaults]
preset = memgpt_chat
persona = sam_pov
human = basic

[model]
model = gpt-4
model_endpoint = https://api.openai.com/v1
model_endpoint_type = openai
context_window = 8192

[embedding]
embedding_endpoint_type = openai
embedding_endpoint = https://api.openai.com/v1
embedding_model = text-embedding-ada-002
embedding_dim = 1536
embedding_chunk_size = 300

[archival_storage]
type = postgres
path = /Users/gui/.memgpt/chroma
uri = postgresql://postgres:postgres@127.0.0.1:54322/postgres

[recall_storage]
type = postgres
path = /Users/gui/.memgpt
uri = postgresql://postgres:postgres@127.0.0.1:54322/postgres

[metadata_storage]
type = postgres
path = /Users/gui/.memgpt
uri = postgresql://postgres:postgres@127.0.0.1:54322/postgres

[version]
memgpt_version = 0.3.15

[client]
anon_clientid = 00000000-0000-0000-0000-000000000000
gcalabria commented 5 months ago

I've modified the GetAgentResponse to expect UUIDs instead, and it is working fine for me. If you want, I can open a PR

scenaristeur commented 2 months ago

seems to be same as https://github.com/cpacker/MemGPT/issues/1664 should be fixed by https://github.com/cpacker/MemGPT/pull/1679 when merged