-
Notifications
You must be signed in to change notification settings - Fork 292
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(ai): fix renders for empty toolUse messages #5799
Conversation
🦋 Changeset detectedLatest commit: cbd0f70 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
export const ResponseComponentsContext = | ||
React.createContext<ResponseComponentsContextProps>(undefined); | ||
|
||
const prependResponseComponents = (responseComponents?: ResponseComponents) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes it so that we have to run this utility every time responseComponents changes, which responseComponents is set on the createAIConversation
so it shouldnt be changing much if at all
@@ -4,9 +4,22 @@ import { ToolConfiguration } from '../../../types'; | |||
|
|||
type ResponseComponentsContextProps = ResponseComponents | undefined; | |||
|
|||
export const RESPONSE_COMPONENT_PREFIX = 'UI_'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably overkill and something i usually nitpick, but should we make this more specific by prefixing AMPLIFY_
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, happy to add
@@ -15,7 +28,9 @@ export const ResponseComponentsProvider = ({ | |||
responseComponents?: ResponseComponents; | |||
}): JSX.Element => { | |||
return ( | |||
<ResponseComponentsContext.Provider value={responseComponents}> | |||
<ResponseComponentsContext.Provider | |||
value={prependResponseComponents(responseComponents)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will create a new reference on each render, regardless of whether responseComments
changes. Tbh kind of surprised that the React linting rules aren't complaining
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I guess I'm used to our linting rules complaining abou this if you send in an object like {foo, bar}
so when this didn't complain i was a little unsure lol
Description of changes
sendMessage
utility to send messages with tools that are not renderable in the AIConversation component example below:UI_
to be easier to tell as response component tool uses rather than regular tool usesIssue #, if available
Description of how you validated changes
Checklist
yarn test
passes and tests are updated/addeddocs
,e2e
,examples
, or other private packages.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.