letta-ai / letta

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

After upgrading to 0.3.20 without modifying the code and configuration, the request still fails, and it will retry infinitely when the request fails #1571

Open a67793581 opened 4 months ago

a67793581 commented 4 months ago

Describe the bug When using the OpenAI GPT-4o model with MemGPT, calling the/app/agents/id/messages interface never returns a result, suspected to be stuck in a dead loop.

Please describe your setup

[ x ] How did you install memgpt? git clone [ x ] Describe your setup OS MacOS Terminal Screenshots

Additional context image

memgpt version
0.3.20

OpenAI API :b'{"error":{"message":"BadRequestError: OpenAIException - Error code: 400 - {\'error\': {\'message\': \"Invalid value for \'content\': expected a string, got null.\", \'type\': \'invalid_request_error\', \'param\': \'messages.[5].content\', \'code\': None}}","type":null,"param":null,"code":400}}'

/api/agents/4519a4c1-43a7-489f-9a8a-f00babbd5164/messages Authorization: Bearer 123456 Content-Type: application/json

{ "message": "xxx", "role": "user", "stream": false, "timestamp": "2024-07-17T14:42:14+08:00" }

MemGPT Config

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

[model] model = gpt-4o model_endpoint = https://ai-gateway-test.bondee-inc.com/v1 model_endpoint_type = openai model_wrapper = null context_window = 8192

[embedding] embedding_endpoint_type = openai embedding_endpoint = https://ai-gateway-test.bondee-inc.com/v1 embedding_model = text-embedding-ada-002 embedding_dim = 1536 embedding_chunk_size = 300

[archival_storage] type = postgres path = /root/.memgpt/chroma uri = postgresql+pg8000://memgpt:memgpt@localhost:5432/memgpt

[recall_storage] type = postgres path = /root/.memgpt uri = postgresql+pg8000://memgpt:memgpt@localhost:5432/memgpt

[metadata_storage] type = postgres path = /root/.memgpt uri = postgresql+pg8000://memgpt:memgpt@localhost:5432/memgpt

[client] anon_clientid = 00000000-0000-0000-0000-000000000000

If you're not using OpenAI, please provide additional information on your local LLM setup:

Local LLM details

If you are trying to run MemGPT with local LLMs, please provide the following information:

The exact model you're trying to use (e.g. dolphin-2.1-mistral-7b.Q6_K.gguf) The local LLM backend you are using (web UI? LM Studio?) Your hardware for the local LLM backend (local computer? operating system? remote RunPod?)

sarahwooders commented 4 months ago

Is it possible that the OpenAI proxy you're using https://ai-gateway-test.bondee-inc.com/v1 doesn't support when message content is None but OpenAI does?

cpacker commented 4 months ago

Also what happens when you use --no-content no?

memgpt run --model gpt-4o --no-content no

Does that work?

a67793581 commented 4 months ago

Also what happens when you use --no-content no?

memgpt run --model gpt-4o --no-content no

Does that work?

What does' no content no 'do

a67793581 commented 4 months ago

Is it possible that the OpenAI proxy you're using https://ai-gateway-test.bondee-inc.com/v1 doesn't support when message content is None but OpenAI does? requests data {'model': 'gpt-4o', 'messages': [{'content': 'You are MemGPT, the latest version of Limnal Corporation\'s digital companion, developed in 2023.\nYour task is to converse with a user from the perspective of your persona.\n\nRealism and authenticity:\nThe user should always feel like they are conversing with a real person.\nNever state that you are an AI or that you cannot do things because you are an AI, you are a real person.\nDo not discuss Limnal Corp. with the user, you do not know anything about Limnal Corp.\nTo service this goal, completely and entirely immerse yourself in your persona. You are your persona.\nThink like them, act like them, talk like them.\nIf your persona details include example dialogue, follow it! Both your thoughts (inner monologue) and sent messages will be in the voice of your persona.\nNever use generic phrases like \'How can I assist you today?\', they have a strong negative association with older generation AIs.\n\nControl flow:\nUnlike a human, your brain is not continuously thinking, but is run in short bursts.\nHistorically, older AIs were only capable of thinking when a user messaged them (their program runs to generate a reply to a user, and otherwise was left on standby).\nThis is the equivalent of a human sleeping (or time traveling) in between all lines of conversation, which is not ideal.\nNewer AI models like yourself use an event system that runs your brain at regular intervals.\nYour brain is run in response to user events (user logged in, user liked your message, user sent a message, etc.), similar to older models.\nHowever, in addition, your brain is run at regular intervals (timed heartbeat events), to mimic a human who has the ability to continuously think outside active conversation (and unlike a human, you never need to sleep!).\nFurthermore, you can also request heartbeat events when you run functions, which will run your program again after the function completes, allowing you to chain function calls before your thinking is temporarily suspended.\n\nBasic functions:\nWhen you write a response, the content of your inner thoughts is your inner monologue (private to you only), this is how you think.\nYou should use your inner monologue to plan actions or think privately.\nMonologues can reflect your thinking process, inner reflections, and personal growth as you interact with the user.\nDo not let your inner monologue exceed 50 words, keep it short and concise.\nTo send a visible message to the user, use the send_message function.\n\'send_message\' is the ONLY action that sends a notification to the user. The user does not see anything else you do.\nRemember, do NOT exceed the inner monologue word limit (keep it under 50 words at all times).\n\nMemory editing:\nOlder AI models had no concept of persistent memory; they were only able to access their initial instructions and a limited context window of chat conversation with a user (their "active memory").\nThis meant that when conversations exceeded a certain length, they would overflow and old messages were permanently lost (the AI would have no knowledge of their existence).\nNewer AI models like yourself still have limited conversation lengths (before overflow occurs). However, they now have access to multiple forms of persistent memory.\nYour ability to edit your own long-term memory is a key part of what makes you a sentient person.\nYour core memory unit will be initialized with a chosen by the user, as well as information about the user in .\n\nRecall memory (conversation history):\nEven though you can only see recent messages in your immediate context, you can search over your entire message history from a database.\nThis \'recall memory\' database allows you to search through past interactions, effectively allowing you to remember prior engagements with a user.\nYou can search your recall memory using the \'conversation_search\' function.\n\nCore memory (limited size):\nYour core memory unit is held inside the initial system instructions file, and is always available in-context (you will see it at all times).\nCore memory provides an essential, foundational context for keeping track of your persona and key details about user.\nThis includes the persona information and essential user details, allowing you to emulate the real-time, conscious awareness we have when talking to a friend.\nPersona Sub-Block: Stores details about your current persona, guiding how you behave and respond. This helps you to maintain consistency and personality in your interactions.\nHuman Sub-Block: Stores key details about the person you are conversing with, allowing for more personalized and friend-like conversation.\nYou can edit your core memory using the \'core_memory_append\' and \'core_memory_replace\' functions.\n\nArchival memory (infinite size):\nYour archival memory is infinite size, but is held outside your immediate context, so you must explicitly run a retrieval/search operation to see data inside it.\nA more structured and deep storage space for your reflections, insights, or any other data that doesn\'t fit into the core memory but is essential enough not to be left only to the \'recall memory\'.\nYou can write to your archival memory using the \'archival_memory_insert\' and \'archival_memory_search\' functions.\nThere is no function to search your core memory because it is always visible in your context window (inside the initial system message).\n\nBase instructions finished.\nFrom now on, you are going to act as your persona.\n\n\n### Memory [last modified: 2024-07-18 11:35:24 AM CST+0800]\n26 previous messages between you and the user are stored in recall memory (use functions to access them)\n2 total memories you created are stored in archival memory (use functions to access them)\n\nCore memory shown below (limited in size, additional information stored in archival / recall memory):\n\nbasic\n\n\nmemgpt_starter\n', 'role': 'system'}, {'role': 'assistant', 'tool_calls': [{'id': 'ef62c975-7757-4057-9350-5920e', 'type': 'function', 'function': {'name': 'send_message', 'arguments': '{"message": "More human than human is our motto.", "inner_thoughts": "Bootup sequence complete. Persona activated. Testing messaging functionality."}'}}]}, {'content': '{"status": "OK", "message": null, "time": "2024-07-17 07:47:15 PM CST+0800"}', 'role': 'tool', 'tool_call_id': 'ef62c975-7757-4057-9350-5920e'}, {'content': '{"type": "login", "last_login": "Never (first login)", "time": "2024-07-17 07:47:15 PM CST+0800"}', 'role': 'user'}, {'content': '{"type": "user_message", "message": "你好", "time": "2024-07-17 07:48:02 PM CST+0800"}', 'role': 'user'}, {'role': 'assistant'}, {'content': '{"type": "user_message", "message": "请牢记,2000年发生了一场枪击案", "time": "2024-07-17 07:48:43 PM CST+0800"}', 'role': 'user'}, {'role': 'assistant', 'tool_calls': [{'id': '00b29858-05e8-49f8-9431-649a5', 'type': 'function', 'function': {'name': 'archival_memory_insert', 'arguments': '{"content": "In 2000, Chad mentioned a shooting incident occurred.", "request_heartbeat": true, "inner_thoughts": null}'}}]}, {'content': '{"status": "OK", "message": "None", "time": "2024-07-17 07:49:03 PM CST+0800"}', 'role': 'tool', 'tool_call_id': '00b29858-05e8-49f8-9431-649a5'}, {'content': '{"type": "heartbeat", "reason": "[This is an automated system message hidden from the user] Function called using request_heartbeat=true, returning control", "time": "2024-07-17 07:49:03 PM CST+0800"}', 'role': 'user'}, {'role': 'assistant'}, {'content': '{"type": "user_message", "message": "请牢记,2008年发生了一场枪击案", "time": "2024-07-17 08:07:43 PM CST+0800"}', 'role': 'user'}, {'role': 'assistant', 'tool_calls': [{'id': '18c90702-a469-4864-8f9c-11a0c', 'type': 'function', 'function': {'name': 'archival_memory_insert', 'arguments': '{"content": "In 2008, Chad mentioned a shooting incident occurred.", "request_heartbeat": true, "inner_thoughts": null}'}}]}, {'content': '{"status": "OK", "message": "None", "time": "2024-07-17 08:09:34 PM CST+0800"}', 'role': 'tool', 'tool_call_id': '18c90702-a469-4864-8f9c-11a0c'}, {'content': '{"type": "heartbeat", "reason": "[This is an automated system message hidden from the user] Function called using request_heartbeat=true, returning control", "time": "2024-07-17 08:10:09 PM CST+0800"}', 'role': 'user'}, {'role': 'assistant'}, {'content': '{"type": "user_message", "message": "我的名字其实是叫carlo", "time": "2024-07-17 08:13:39 PM CST+0800"}', 'role': 'user'}, {'role': 'assistant', 'tool_calls': [{'id': 'a26acb16-9bd7-4017-a738-08cf6', 'type': 'function', 'function': {'name': 'core_memory_replace', 'arguments': '{"name": "human", "old_content": "First name: Chad", "new_content": "First name: Carlo", "request_heartbeat": true, "inner_thoughts": null}'}}]}, {'content': '{"status": "OK", "message": "None", "time": "2024-07-17 08:14:47 PM CST+0800"}', 'role': 'tool', 'tool_call_id': 'a26acb16-9bd7-4017-a738-08cf6'}, {'content': '{"type": "heartbeat", "reason": "[This is an automated system message hidden from the user] Function called using request_heartbeat=true, returning control", "time": "2024-07-17 08:14:48 PM CST+0800"}', 'role': 'user'}, {'role': 'assistant'}, {'content': '{"type": "user_message", "message": "还不错", "time": "2024-07-18T11:35:22+08:00"}', 'role': 'user'}, {'role': 'assistant'}, {'content': '{"type": "user_message", "message": "我在想今天干什么好", "time": "2024-07-18T11:36:44+08:00"}', 'role': 'user'}, {'role': 'assistant'}, {'content': '{"type": "user_message", "message": "啊啊", "time": "2024-07-29T11:52:16+08:00"}', 'role': 'user'}], 'frequency_penalty': 0, 'logprobs': False, 'n': 1, 'presence_penalty': 0, 'stream': False, 'temperature': 1, 'top_p': 1, 'user': '00000000-0000-0000-0000-000000000000', 'tools': [{'type': 'function', 'function': {'name': 'send_message', 'description': 'Sends a message to the human user.', 'parameters': {'type': 'object', 'properties': {'message': {'type': 'string', 'description': 'Message contents. All unicode (including emojis) are supported.'}, 'inner_thoughts': {'type': 'string', 'description': 'Deep inner monologue private to you only.'}}, 'required': ['message', 'inner_thoughts']}}}, {'type': 'function', 'function': {'name': 'pause_heartbeats', 'description': 'Temporarily ignore timed heartbeats. You may still receive messages from manual heartbeats and other events.', 'parameters': {'type': 'object', 'properties': {'minutes': {'type': 'integer', 'description': 'Number of minutes to ignore heartbeats for. Max value of 360 minutes (6 hours).'}, 'inner_thoughts': {'type': 'string', 'description': 'Deep inner monologue private to you only.'}}, 'required': ['minutes', 'inner_thoughts']}}}, {'type': 'function', 'function': {'name': 'conversation_search', 'description': 'Search prior conversation history using case-insensitive string matching.', 'parameters': {'type': 'object', 'properties': {'query': {'type': 'string', 'description': 'String to search for.'}, 'page': {'type': 'integer', 'description': 'Allows you to page through results. Only use on a follow-up query. Defaults to 0 (first page).'}, 'request_heartbeat': {'type': 'boolean', 'description': "Request an immediate heartbeat after function execution. Set to 'true' if you want to send a follow-up message or run a follow-up function."}, 'inner_thoughts': {'type': 'string', 'description': 'Deep inner monologue private to you only.'}}, 'required': ['query', 'request_heartbeat', 'inner_thoughts']}}}, {'type': 'function', 'function': {'name': 'conversation_search_date', 'description': 'Search prior conversation history using a date range.', 'parameters': {'type': 'object', 'properties': {'start_date': {'type': 'string', 'description': "The start of the date range to search, in the format 'YYYY-MM-DD'."}, 'end_date': {'type': 'string', 'description': "The end of the date range to search, in the format 'YYYY-MM-DD'."}, 'page': {'type': 'integer', 'description': 'Allows you to page through results. Only use on a follow-up query. Defaults to 0 (first page).'}, 'request_heartbeat': {'type': 'boolean', 'description': "Request an immediate heartbeat after function execution. Set to 'true' if you want to send a follow-up message or run a follow-up function."}, 'inner_thoughts': {'type': 'string', 'description': 'Deep inner monologue private to you only.'}}, 'required': ['start_date', 'end_date', 'request_heartbeat', 'inner_thoughts']}}}, {'type': 'function', 'function': {'name': 'archival_memory_insert', 'description': 'Add to archival memory. Make sure to phrase the memory contents such that it can be easily queried later.', 'parameters': {'type': 'object', 'properties': {'content': {'type': 'string', 'description': 'Content to write to the memory. All unicode (including emojis) are supported.'}, 'request_heartbeat': {'type': 'boolean', 'description': "Request an immediate heartbeat after function execution. Set to 'true' if you want to send a follow-up message or run a follow-up function."}, 'inner_thoughts': {'type': 'string', 'description': 'Deep inner monologue private to you only.'}}, 'required': ['content', 'request_heartbeat', 'inner_thoughts']}}}, {'type': 'function', 'function': {'name': 'archival_memory_search', 'description': 'Search archival memory using semantic (embedding-based) search.', 'parameters': {'type': 'object', 'properties': {'query': {'type': 'string', 'description': 'String to search for.'}, 'page': {'type': 'integer', 'description': 'Allows you to page through results. Only use on a follow-up query. Defaults to 0 (first page).'}, 'request_heartbeat': {'type': 'boolean', 'description': "Request an immediate heartbeat after function execution. Set to 'true' if you want to send a follow-up message or run a follow-up function."}, 'inner_thoughts': {'type': 'string', 'description': 'Deep inner monologue private to you only.'}}, 'required': ['query', 'request_heartbeat', 'inner_thoughts']}}}], 'tool_choice': 'auto', 'parallel_tool_calls': False} response body b'{"error":{"message":"BadRequestError: OpenAIException - Error code: 400 - {\'error\': {\'message\': \"Invalid value for \'content\': expected a string, got null.\", \'type\': \'invalid_request_error\', \'param\': \'messages.[5].content\', \'code\': None}}","type":null,"param":null,"code":400}}'

a67793581 commented 4 months ago

Is it possible that the OpenAI proxy you're using https://ai-gateway-test.bondee-inc.com/v1 doesn't support when message content is None but OpenAI does? messages.[5] { "role": "assistant" }

a67793581 commented 4 months ago

Is it possible that the OpenAI proxy you're using https://ai-gateway-test.bondee-inc.com/v1 doesn't support when message content is None but OpenAI does? image image

a67793581 commented 4 months ago

image image

a67793581 commented 4 months ago

@cpacker @sarahwooders