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 (ui): introduce message parts for useChat #4670

Merged
merged 67 commits into from
Feb 5, 2025
Merged

feat (ui): introduce message parts for useChat #4670

merged 67 commits into from
Feb 5, 2025

Conversation

lgrammel
Copy link
Collaborator

@lgrammel lgrammel commented Feb 3, 2025

Background

Text fields on Message for content and reasoning do not support multi-step invocations. A mechanism for support many message parts is needed to properly represent complex user messages and assistant responses.

Tasks

  • implementation
    • update in addToolResult
      • react
      • svelte
      • solid
      • vue
    • function that fills in parts for existing ui messages
      • react
      • svelte
      • solid
      • vue
      • fill should have msg at end if it's a single message
    • auto-fill in parts when processing response
    • appendResponseMessages function needs to fill in parts
    • map to core messages based on parts
      • support anthropic-like ordering
    • support parts in text protocol responses
    • update in automatic client side tool execution
    • start new reasoning / new text part on new step
    • update re-submit check to work with anthropic
      • react
      • svelte
      • solid
      • vue
    • useAssistant compatibility fixes
      • react
      • svelte
      • solid
      • vue
    • deprecate message, reasoning, toolInvocations
    • useChat append must have optional parts; fill them in
      • react
      • svelte
      • solid
      • vue
    • send parts to server
      • react
      • svelte
      • solid
      • vue
  • examples & manual testing
    • anthropic
    • resuming old conversation
    • storing single message
    • vue
    • solid
    • react
    • svelte
  • documentation
    • message reference
    • chatbot with tools guide
    • chatbot guide
    • jsdoc for parts
  • changeset

Stored old conversation for reference

[
  {
    "id": "msgc-HsgNJ3TURcE5lGkm",
    "createdAt": "2025-01-30T11:33:23.885Z",
    "role": "user",
    "content": "what is the weather  at my current location "
  },
  {
    "id": "msgs-2ySYamF9UyKoeUmm",
    "createdAt": "2025-01-30T11:33:23.978Z",
    "role": "assistant",
    "content": "The current weather in Los Angeles is rainy.",
    "annotations": [
      {
        "start": "start",
        "count": 1
      }
    ],
    "toolInvocations": [
      {
        "state": "result",
        "step": 0,
        "toolCallId": "call_cMbBQGbGCvHZDy5AQKqpIekC",
        "toolName": "askForConfirmation",
        "args": {
          "message": "Can I access your current location to provide the weather information?"
        },
        "result": "Yes, confirmed."
      },
      {
        "state": "result",
        "step": 1,
        "toolCallId": "call_mQ0IevsD0PTpv17iRyOogDsd",
        "toolName": "getLocation",
        "args": {},
        "result": "Los Angeles"
      },
      {
        "state": "result",
        "step": 2,
        "args": {
          "city": "Los Angeles"
        },
        "toolCallId": "call_8DfGRUjtVVoYWumEL19skTQV",
        "toolName": "getWeatherInformation",
        "result": "rainy"
      }
    ],
    "revisionId": "msgc-1mM8ABtpPTzAM1pL"
  }
]

@lgrammel lgrammel changed the title 1 feat (ui): introduce message parts for useChat Feb 3, 2025
@lgrammel lgrammel marked this pull request as ready for review February 5, 2025 08:59
@@ -10,6 +11,7 @@ export async function POST(req: Request) {

const result = streamText({
model: openai('gpt-4o'),
// model: anthropic('claude-3-5-sonnet-latest'),
Copy link
Contributor

Choose a reason for hiding this comment

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

stray comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

wanted to leave it in for future testing

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