-
Notifications
You must be signed in to change notification settings - Fork 117
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(ai-chat-log): add new AI Chat Log components #3927
Conversation
Run & review this pull request in StackBlitz Codeflow. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
🦋 Changeset detectedLatest commit: 8c473a8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
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 |
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 8c473a8. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
Size Change: +286 B (0%) Total Size: 1.05 MB
ℹ️ View Unchanged
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 8c473a8:
|
Passing run #8128 ↗︎
Details:
Review all test suite changes for PR #3927 ↗︎ |
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.
Overall looks good, but I'm wondering about some of the API definition.
push: PushAIChat; | ||
pop: PopAIChat; | ||
clear: () => void; | ||
}; |
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.
I'm wondering about this API. Do you know why Shadi decided on this?
- It seems that what I would otherwise call a message is considered an "Ai Chat" entity here. Usually I would think Chat is equal to Conversation, so one Chat would contain of many Messages.
So I would usually think messages would be more appropriate prop here. Also what OpenAI uses, some other LLMs for their API.
The second thing, I'm not sure if it's good to have initialChats as a parameter that alone is a spread array.
It would narrow down anything you could pass there in the future. I would suggest having an object to pass as config where you could have initialMessages prop. Like react-hook-form has initialValues.
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.
These are both good points. The reason we went with these decisions was solely to mirror the existing ChatLog API. Because many consumers are already familiar with that API, we wanted to replicate it as closely as possible with this one.
id: "uid1", | ||
variant: "bot", | ||
content: ( | ||
<AIChatMessage variant="bot"> |
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.
I'm wonder if API usage wise it would be possible to avoid having to pass the variant twice.
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.
Hey @henrieri, when using the hook you would have to define twice but if you're just using the logs you wouldn't need to. With the hook in the previous chat log it controlled the animation direction and we've kept the same logic for this.
This is currently the same way ChatLogger works and we want to maintain consistency between the components as they are so closely related. May make these components more intuitive for developers if they are already using ChatLogger.
@nkrantz we should discuss this though because it would make sense to have something like this in future.
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.
Same as above - agree but we want to mirror ChatLogger API here.
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.
Whoops - didn't see Kristian's comment. Agreed, would be nice to ticket this change across both packages.
"version": "0.0.0", | ||
"category": "data display", | ||
"status": "production", | ||
"description": "Ai chat log.", |
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.
FYI I am updating the package desc in my docs PR
* I18n accessible screen reader text to give context to the "Stop generating" button when `onStopLoading` is passed for non-english languages. Should read as a sentence, e.g. "Stop generating AI response". | ||
* | ||
* @default "AI response" | ||
* @type {string} | ||
* @memberof AIChatMessageLoadingProps | ||
*/ | ||
i18nAIScreenReaderText?: string; |
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.
praise: great addition
{ | ||
onStopLoading, | ||
i18nStopGeneratingLabel = "Stop generating", | ||
i18nAIScreenReaderText = "AI response", |
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.
Should the default text here match the props description? "Stop generating AI response"
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.
It's kind of clunky but I made them 2 separate props - stop generating label and screen reader text. Only the stop generating label gets rendered on the screen, but the text passed into the screen reader text prop goes into a Screen Reader Only component to give screen reader users more context about what stops generating. So a sighted user will see "Stop generating" but a screen reader will read out loud "stop generating AI response"
@@ -79,6 +79,8 @@ export const ButtonGroup = React.forwardRef<HTMLDivElement, ButtonGroupProps>( | |||
ref={ref} | |||
element={element} | |||
display="inline-flex" | |||
flexWrap={attached ? "nowrap" : "wrap"} | |||
rowGap="space40" |
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.
Does this add any additional space below the ButtonGroup is it's attached too? Might impact spacings on rollout to existing pages
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.
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.
Great implementation, left a few minor comments for clarification but very happy! p.s. I cannot approve because I created the PR 😆
packages/paste-core/components/ai-chat-log/src/AIChatMessageAuthor.tsx
Outdated
Show resolved
Hide resolved
packages/paste-core/components/ai-chat-log/src/AIChatMessageActionGroup.tsx
Outdated
Show resolved
Hide resolved
packages/paste-core/components/ai-chat-log/src/AIChatMessageActionGroup.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Sarah <sali@twilio.com>
Passing run #8127 ↗︎
Details:
Review all test suite changes for PR #3927 ↗︎ |
AI Chat Log
Originally branched from Shadi's original PR
Adds several new components: