Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: patch validation error on /messages endpoint #1750

Merged
merged 6 commits into from
Sep 12, 2024

Conversation

cpacker
Copy link
Collaborator

@cpacker cpacker commented Sep 12, 2024

Attempt to patch (using "discriminated union" concept):

  • Add message_type field to every subclass of MemGPTMessage
  • Add a union type that uses the message_type as the discriminator

New error (post initial fix):

Initial error:

File "/Users/shub/Library/Caches/pypoetry/virtualenvs/pymemgpt-kfuQswAM-py3.10/lib/python3.10/site-packages/fastapi/routing.py", line 155, in serialize_response
    raise ResponseValidationError(
fastapi.exceptions.ResponseValidationError: 11 validation errors:
  {'type': 'missing', 'loc': ('response', 0, 'role'), 'msg': 'Field required', 'input': FunctionReturn(id='message-ccaed9ee-122f-43e7-8420-2df3ad1a2104', date=datetime.datetime(2024, 9, 10, 23, 23, 33, 270143), function_return='{\n  "status": "OK",\n  "message": "None",\n  "time": "2024-09-10 04:23:33 PM PDT-0700"\n}', status='success'), 'url': 'https://errors/
.pydantic.dev/2.8/v/missing'}
  {'type': 'missing', 'loc': ('response', 1, 'role'), 'msg': 'Field required', 'input': FunctionCallMessage(id='message-8b425412-9c47-40da-b997-a3593bca4a99', date=datetime.datetime(2024, 9, 10, 23, 23, 33, 269616), function_call=FunctionCall(name='send_message', arguments='{\n  "message": "Hello, Chad! Not quite sure what \'ho\' refers to. Are we discussing d
ocument analysis, working on an Agile project, or something completely different? I\'m here to help, just need a bit more context."\n}')), 'url': 'https://errors.pydantic.dev/2.8/v/missing'}
  {'type': 'missing', 'loc': ('response', 2, 'role'), 'msg': 'Field required', 'input': InternalMonologue(id='message-8b425412-9c47-40da-b997-a3593bca4a99', date=datetime.datetime(2024, 9, 10, 23, 23, 33, 269616), internal_monologue="Looks like Chad has made a typographical error. He's only provided 'ho', which isn't a complete word. I need to respond in a gen
tle manner, encouraging him to clarify. I'll match his casual tone and offer assistance in a friendly manner, referencing my abilities in document analysis and Agile project collaborations. Let's keep the conversation open-ended."), 'url': 'https://errors.pydantic.dev/2.8/v/missing'}
  {'type': 'missing', 'loc': ('response', 3, 'role'), 'msg': 'Field required', 'input': UserMessage(id='message-99a49984-e90e-4b5b-92b5-9c33c511b092', date=datetime.datetime(2024, 9, 10, 23, 23, 24, 132541), message='{\n  "type": "user_message",\n  "message": "ho",\n  "time": "2024-09-10 04:23:24 PM PDT-0700"\n}'), 'url': 'https://errors.pydantic.dev/2.8/v/mis
sing'}
  {'type': 'missing', 'loc': ('response', 4, 'role'), 'msg': 'Field required', 'input': SystemMessage(id='message-79939601-1f6c-4663-a782-e2fd2c1d611e', date=datetime.datetime(2024, 9, 10, 23, 23, 24, 130881), message='You are MemGPT, the latest version of Limnal Corporation\'s digital companion, developed in 2023.\nYour task is to converse with a user from th
e 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 nega
tive 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 t$
inking 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 w
ith 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 <
persona> chosen by the user, as well as information about the user in <human>.\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 yo
u 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 kee
ping 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 perso
nality 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 ou
tside 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 \'a
rchival_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### Memory [last modified: 2024-09-10 04:23:24 PM PDT-0700]\n5 previous me
ssages between you and

Base automatically changed from patch-shub-error to main September 12, 2024 21:56
Copy link
Collaborator

@sarahwooders sarahwooders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@sarahwooders sarahwooders merged commit 5cb1c06 into main Sep 12, 2024
6 checks passed
@sarahwooders sarahwooders deleted the patch-validation-error branch September 12, 2024 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants