Skip to content

ai-sdk/ui: Provide a way to customise the user message in useChat  #2987

Closed
@sahas-si

Description

@sahas-si

Feature Description

Creating this enhancement issue as suggested by @lgrammel in this thread -> #2820

Current Scenario: In a conversation, user asks a query & assistant provides an answer. Both the query and response are represented as messages. By default, useChat's handleSubmit method generates the user's message & appends it to messages. There can be no customisation & its fixed.

Requirement: Many a times, user message can have more than a query/text, there could be an extra filters that user has selected. (Check the usecaseProvide a way for the user to add more attributes to the user's message either through a callback or via any other mechanism

Current code:
image

Use Case

Here's our usecase. We have a stock market based chat assistant. While asking a query, users can select the year/quarter/filing type from the filters & send these filters to the API. The user can update these filters for every new query.

Right now, its not possible to render these filters as part of user's message in the UI as the handleSubmit already generates the message on its own with just the text.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions