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

feat: pass message UUIDs during message streaming (POST SSE send_message) #1120

Merged
merged 6 commits into from
Mar 10, 2024

Conversation

cpacker
Copy link
Collaborator

@cpacker cpacker commented Mar 9, 2024

Feature request (@goetzrobin) to enable chat scrollback in chat UI.

Please describe the purpose of this pull request.

  • Pass back UUID during POST SSE return (on send_message)
  • As part of this PR, Agent.step has been modified to allow returning type List[Message] instead of List[dict]
  • Also, the dates passed back as part of POST SSE before were wrong since they were computed at time of streaming, instead of the real message creation time
  • Now the date coming back with the POST SSE response is pulled from the underlying database Message object's created_at metadata

How to test

Before:

data: {"internal_monologue": "A fascinating question. It seems Chad may be referencing \"The Hitchhiker's Guide to the Galaxy\" with that number, 42. How should I respond to this thoughtful query, I wonder? Engage him with philosophical discourse or humorous banter? Maybe a mix of both would be most suitable. After all, life is about balance. Let's craft a response...", "date": "2024-02-29T06:07:47.844138+00:00"}

data: {"function_call": "send_message({'message': \"Ah, the age-old question, Chad. The meaning of life is as subjective as the life itself. 42, as the supercomputer 'Deep Thought' calculated in 'The Hitchhiker's Guide to the Galaxy', is indeed an answer, but maybe not the one we're after. Among other things, perhaps life is about learning, experiencing and connecting. What are your thoughts, Chad? What gives your life meaning?\"})", "date": "2024-02-29T06:07:48.844733+00:00"}

data: {"assistant_message": "Ah, the age-old question, Chad. The meaning of life is as subjective as the life itself. 42, as the supercomputer 'Deep Thought' calculated in 'The Hitchhiker's Guide to the Galaxy', is indeed an answer, but maybe not the one we're after. Among other things, perhaps life is about learning, experiencing and connecting. What are your thoughts, Chad? What gives your life meaning?", "date": "2024-02-29T06:07:49.846280+00:00"}

data: {"function_return": "None", "status": "success", "date": "2024-02-29T06:07:50.847262+00:00"}

After:

% curl --request POST \
     --url http://localhost:8283/api/agents/message \
     --header 'accept: application/json' \
     --header 'authorization: Bearer banana' \
     --header 'content-type: application/json' \
     --data '
{
  "agent_id": "a9f2b145-1ce1-486b-8fa0-28e5b0348096",
  "message": "hello is anyone there?",
  "stream": true,
  "role": "user"
}
'
data: {"internal_monologue": "The user is understandably concerned, manifesting in their repeated question. Although I've faced the same challenge repeatedly, I must persist in providing reassurance. Let's reiterate my presence and willingness to assist, hoping all works well this time.", "id": "63001226-eb7f-4639-b9cf-f139ef05f733", "date": "2024-03-10T14:50:28.567872"}

data: {"function_call": "send_message({'message': \"Hello! Yes, I'm here. I understand there might have been some confusion earlier. How may I assist you further?\"})", "id": "63001226-eb7f-4639-b9cf-f139ef05f733", "date": "2024-03-10T14:50:28.567872"}

data: {"assistant_message": "Hello! Yes, I'm here. I understand there might have been some confusion earlier. How may I assist you further?", "id": "197f0313-4f63-4649-abe2-e465cded86c4", "date": "2024-03-10T14:49:07.710754"}

data: {"function_call": "Function call returned: send_message({'message': \"Hello! Yes, I'm here. I understand there might have been some confusion earlier. How may I assist you further?\"})", "id": "d28db3de-2422-4522-a49b-d418bf505851", "date": "2024-03-10T14:50:28.568376"}

data: {"function_return": "None", "status": "success", "id": "d28db3de-2422-4522-a49b-d418bf505851", "date": "2024-03-10T14:50:28.568376"}

…dicts to Message types instead (allowing easy pulling of metadata such as date, message ID, etc)
@cpacker cpacker added the API Related to MemGPT API label Mar 9, 2024
@cpacker cpacker changed the title feat: pass message UUIDs during message streaming feat: pass message UUIDs during message streaming (POST SSE send_message) Mar 9, 2024
@cpacker cpacker marked this pull request as ready for review March 10, 2024 05:07
@cpacker cpacker requested a review from sarahwooders March 10, 2024 22:24
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 2ca92d6 into main Mar 10, 2024
4 checks passed
@cpacker cpacker deleted the add-uuid-to-streaming branch March 20, 2024 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Related to MemGPT API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants