-
Notifications
You must be signed in to change notification settings - Fork 119
feat(ai-chat-log): Adding docs for new component #3963
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
Merged
Merged
Changes from 71 commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
b22cdd1
chore: checkpoint ai log and ai msg
TheSisb 5c21b5b
chore: checkpoint
TheSisb 6a8f9de
chore: checkpoint more progress
TheSisb e4984c3
Merge branch 'main' of github.com:twilio-labs/paste into ai-kit/logs-v2
krisantrobus f51a267
chore: typo fix
krisantrobus e0fffdf
chore: wip working useAILogger
krisantrobus 8437c06
feat: message typewriter component
krisantrobus b35952f
chore: working typewriter
krisantrobus 6fe0f56
chore: name cleanup and JSDoc
krisantrobus bb64b73
chore: lint updates
krisantrobus a7d924f
chore: chageset
krisantrobus 5ee7cf4
chore: fix lint & build
krisantrobus 925fd0a
chore: build update
krisantrobus 9cb001a
chore: yarn update
krisantrobus 2d941d0
Merge branch 'main' into ai-kit/logs-v2
nkrantz 9dcf2db
chore: cleanup, renaming, small refactors
nkrantz 6e627ec
chore(docs): ai chat log init
krisantrobus 9da6bcf
chore(docs): functional init
krisantrobus 6bdfff2
chore(docs): new sections complete with examples
krisantrobus 64b9cfd
chore(docs): wip
krisantrobus b210d2c
chore(docs): merge branch 'ai-kit/logs-v2' of github.com:twilio-labs/…
krisantrobus 0407ea3
chore(docs): update package decription
krisantrobus ba59388
chore(docs): chat log typo
krisantrobus ab9835e
chore(docs): renaming for enw imports and AIChatLogger example
krisantrobus 369cad7
chore(docs): loading notes and removal of action buttons
krisantrobus 2c6d0a2
chore(docs): reference other type of ChatLog
krisantrobus 173a752
chore: checkpoint ai log and ai msg
TheSisb 90310f2
chore: checkpoint
TheSisb fe3e6bb
chore: checkpoint more progress
TheSisb 26de793
chore: typo fix
krisantrobus 0f27f00
chore: wip working useAILogger
krisantrobus 3f6fff4
feat: message typewriter component
krisantrobus b1b8bed
chore: working typewriter
krisantrobus 2da7c1a
chore: name cleanup and JSDoc
krisantrobus 86c31f3
chore: lint updates
krisantrobus 2d05ede
chore: chageset
krisantrobus 954b8a8
chore: fix lint & build
krisantrobus 9f64266
chore: build update
krisantrobus ccaa288
chore: yarn update
krisantrobus dcf1a75
chore: cleanup, renaming, small refactors
nkrantz 3346998
chore: animations
nkrantz 3b07554
chore: refactors renaming and composer story
nkrantz 9baedf4
feat(button): allow `pressed` on reset buttons
nkrantz 7584fde
test: add tests and update stories
nkrantz c7c914e
chore: type docs
nkrantz dab49e1
chore: codemods changeset
nkrantz 5cfe884
chore(docs): merge branch 'ai-kit/logs-v2' of github.com:twilio-labs/…
krisantrobus f1b742c
chore(docs): ai logs update
krisantrobus 53bae02
chore(docs): ui logs update
krisantrobus a670e5f
chore(docs): revert flex test
krisantrobus 4d91f51
chore(docs): ia logs update
krisantrobus 3b9fa3f
chore(button): undo toggle reset change and add border radius to reset
nkrantz 755d8d9
chore(button-group): flex unattached groups
nkrantz e61f918
chore: actioin card changes from huddle
nkrantz 3580d95
chore: update all stories with changes
nkrantz 94a4000
chore: typedocs
nkrantz de58ef1
Merge branch 'ai-kit/logs-v2' of github.com:twilio-labs/paste into do…
krisantrobus 3fb49a3
chore(docs): update action card naming
krisantrobus 29f68f9
chore(docs): cleanup PR
krisantrobus 634fabe
chore(docs): add vrt for new docs pages
krisantrobus 732f39b
chore(docs): merge branch 'main' of github.com:twilio-labs/paste into…
krisantrobus 207c3fb
Merge branch 'main' of github.com:twilio-labs/paste into docs/ai-logs
krisantrobus dede25f
feat(docs): update imports
krisantrobus a06a129
feat(docs): updated imports
krisantrobus ce5e32b
chore(docs): add dependency
krisantrobus 107797f
chore(docs): update lock file
krisantrobus 5dd1810
chore(docs): update descprition
krisantrobus 69a5a15
chore(docs): typo fix
krisantrobus c06291e
Merge branch 'main' of github.com:twilio-labs/paste into docs/ai-log-2
krisantrobus fbe0c69
feat(docs/ai): address PR comments
krisantrobus deddcdd
feat(docs/ai): move buttons to next line
krisantrobus 9e7f85e
Apply suggestions from code review
krisantrobus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
310 changes: 310 additions & 0 deletions
310
packages/paste-website/src/component-examples/AIChatLogExamples.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,310 @@ | ||
export const basicBotMessage = ` | ||
const BasicMessage = () => { | ||
return ( | ||
<AIChatLog> | ||
<AIChatMessage variant="bot"> | ||
<AIChatMessageAuthor aria-label="AI said">Good Bot</AIChatMessageAuthor> | ||
<AIChatMessageBody> | ||
Here is what I found, error code 30003 means: The destination phone is unavailable or turned off, or it may be a landline or phone that doesn't support SMS. | ||
</AIChatMessageBody> | ||
</AIChatMessage> | ||
</AIChatLog> | ||
); | ||
}; | ||
|
||
render( | ||
<BasicMessage /> | ||
)`.trim(); | ||
export const basicHumanMessage = ` | ||
const BasicMessage = () => { | ||
return ( | ||
<AIChatLog> | ||
<AIChatMessage variant="user"> | ||
<AIChatMessageAuthor aria-label="You said at 2:36pm">Gibby Radki</AIChatMessageAuthor> | ||
<AIChatMessageBody> | ||
I would like some information on twilio error codes for undelivered messages | ||
</AIChatMessageBody> | ||
</AIChatMessage> | ||
</AIChatLog> | ||
); | ||
}; | ||
|
||
render( | ||
<BasicMessage /> | ||
)`.trim(); | ||
export const botWithFeedback = ` | ||
const MessageWithFeedback = () => { | ||
return ( | ||
<AIChatLog> | ||
<AIChatMessage variant="bot"> | ||
<AIChatMessageAuthor aria-label="AI said">Good Bot</AIChatMessageAuthor> | ||
<AIChatMessageBody> | ||
Here is what I found, error code 30003 means: The destination phone is unavailable or turned off, or it may be a landline or phone that doesn't support SMS. | ||
</AIChatMessageBody> | ||
<AIChatMessageActionGroup> | ||
<AIChatMessageActionCard aria-label="Feedback form"> | ||
Is this helpful? | ||
<Button variant="reset" size="reset" aria-label="this is a helpful response"> | ||
<ThumbsUpIcon decorative={false} title="like result" /> | ||
</Button> | ||
<Button variant="reset" size="reset"> | ||
<ThumbsDownIcon decorative={false} title="dislike result" aria-label="this is not a helpful response" /> | ||
</Button> | ||
</AIChatMessageActionCard> | ||
<AIChatMessageActionCard aria-label="Rewrite and copy buttons"> | ||
<Button variant="reset" size="reset"> | ||
<RefreshIcon decorative={true}/> Rewrite | ||
</Button> | ||
<Button variant="reset" size="reset"> | ||
<CopyIcon decorative={true}/> Copy | ||
</Button> | ||
</AIChatMessageActionCard> | ||
</AIChatMessageActionGroup> | ||
</AIChatMessage> | ||
</AIChatLog> | ||
); | ||
}; | ||
|
||
render( | ||
<MessageWithFeedback /> | ||
)`.trim(); | ||
export const botWithBodyActions = ` | ||
const MessageWithFeedback = () => { | ||
return ( | ||
<AIChatLog> | ||
<AIChatMessage variant="bot"> | ||
<AIChatMessageAuthor aria-label="AI said">Good Bot</AIChatMessageAuthor> | ||
<AIChatMessageBody> | ||
<Paragraph>Below is a list of actions that can be taken with flex wrapping supported:</Paragraph> | ||
<ButtonGroup> | ||
<Button variant="secondary" size="rounded_small" onClick={() => {}} > | ||
View Logs | ||
</Button> | ||
<Button variant="secondary" size="rounded_small" onClick={() => {}}> | ||
Run Diagnostics | ||
</Button> | ||
<Button variant="secondary" size="rounded_small" onClick={() => {}}> | ||
Submit Bug Report | ||
</Button> | ||
</ButtonGroup> | ||
</AIChatMessageBody> | ||
</AIChatMessage> | ||
</AIChatLog> | ||
); | ||
}; | ||
|
||
render( | ||
<MessageWithFeedback /> | ||
)`.trim(); | ||
export const botWithLoadingStopButton = ` | ||
const MessageWithLoadingAndStop = () => { | ||
return ( | ||
<AIChatLog> | ||
<AIChatMessage variant="bot"> | ||
<AIChatMessageAuthor aria-label="AI said" bot> | ||
Good Bot | ||
</AIChatMessageAuthor> | ||
<AIChatMessageBody> | ||
<AIChatMessageLoading onStopLoading={() => {}} /> | ||
</AIChatMessageBody> | ||
</AIChatMessage> | ||
</AIChatLog> | ||
); | ||
}; | ||
|
||
render( | ||
<MessageWithLoadingAndStop /> | ||
)`.trim(); | ||
export const botWithLoading = ` | ||
const MessageWithLoading = () => { | ||
return ( | ||
<AIChatLog> | ||
<AIChatMessage variant="bot"> | ||
<AIChatMessageAuthor aria-label="AI said" bot> | ||
Good Bot | ||
</AIChatMessageAuthor> | ||
<AIChatMessageBody> | ||
<AIChatMessageLoading /> | ||
</AIChatMessageBody> | ||
</AIChatMessage> | ||
</AIChatLog> | ||
); | ||
}; | ||
|
||
render( | ||
<MessageWithLoading /> | ||
)`.trim(); | ||
export const kitchenSink = ` | ||
const AIChatLogExample = () => { | ||
return ( | ||
<AIChatLog> | ||
<AIChatMessage variant="user"> | ||
<AIChatMessageAuthor aria-label="You said">Gibby Radki</AIChatMessageAuthor> | ||
<AIChatMessageBody> | ||
Hi, I'm getting errors codes when sending an SMS. | ||
</AIChatMessageBody> | ||
</AIChatMessage> | ||
<AIChatMessage variant="bot"> | ||
<AIChatMessageAuthor aria-label="AI said">Good Bot</AIChatMessageAuthor> | ||
<AIChatMessageBody> | ||
<Paragraph>Error codes can be returned from various parts of the process. What error codes are you encountering?</Paragragh> | ||
<ButtonGroup> | ||
<Button variant="secondary" size="rounded_small" onClick={() => {}} > | ||
21608 | ||
</Button> | ||
<Button variant="secondary" size="rounded_small" onClick={() => {}}> | ||
30007 | ||
</Button> | ||
<Button variant="secondary" size="rounded_small" onClick={() => {}}> | ||
30009 | ||
</Button> | ||
</ButtonGroup> | ||
</AIChatMessageBody> | ||
</AIChatMessage> | ||
<AIChatMessage variant="bot"> | ||
<AIChatMessageAuthor aria-label="AI said">Good Bot</AIChatMessageAuthor> | ||
<AIChatMessageBody> | ||
Error 21608 means you're trying to send a message from an unverified number. Is your number verified in your Twilio account? | ||
</AIChatMessageBody> | ||
<AIChatMessageActionGroup> | ||
<AIChatMessageActionCard aria-label="Feedback form"> | ||
Is this helpful? | ||
<Button variant="reset" size="reset" aria-label="this is a helpful response"> | ||
<ThumbsUpIcon decorative={false} title="like result" /> | ||
</Button> | ||
<Button variant="reset" size="reset"> | ||
<ThumbsDownIcon decorative={false} title="dislike result" aria-label="this is not a helpful response"/> | ||
</Button> | ||
</AIChatMessageActionCard> | ||
</AIChatMessageActionGroup> | ||
</AIChatMessage> | ||
<AIChatMessage variant="user"> | ||
<AIChatMessageAuthor aria-label="You said" bot> | ||
Gibby Radki | ||
</AIChatMessageAuthor> | ||
<AIChatMessageBody> | ||
No, how do I verify it? | ||
</AIChatMessageBody> | ||
</AIChatMessage> | ||
<AIChatMessage variant="bot"> | ||
<AIChatMessageAuthor aria-label="AI said" bot> | ||
Good Bot | ||
</AIChatMessageAuthor> | ||
<AIChatMessageBody> | ||
<AIChatMessageLoading onStopLoading={() => {}} /> | ||
</AIChatMessageBody> | ||
</AIChatMessage> | ||
</AIChatLog> | ||
); | ||
}; | ||
|
||
render( | ||
<AIChatLogExample /> | ||
)`.trim(); | ||
export const aiChatLoggerExample = ` | ||
const aiChatFactory = ([ message, variant, metaLabel, meta ]) => { | ||
const time = new Date(0).toLocaleString( | ||
'en-US', | ||
{ hour: 'numeric', minute: 'numeric', timeZone: 'UTC', hour12: true } | ||
) | ||
|
||
return { | ||
variant, | ||
content: ( | ||
<AIChatMessage variant={variant}> | ||
<AIChatMessageAuthor aria-label={metaLabel + time}>{meta}</AIChatMessageAuthor> | ||
<AIChatMessageBody> | ||
{message} | ||
</AIChatMessageBody> | ||
</AIChatMessage> | ||
) | ||
} | ||
}; | ||
|
||
const chatTemplates = [ | ||
["Hello", "user", "You said at ", "Gibby Radki"], | ||
["Hi there", "bot", "AI said at ", "Good Bot"], | ||
["Greetings", "user", "You said at ", "Gibby Radki"], | ||
["Good to meet you", "bot", "AI said at ", "Good Bot"] | ||
]; | ||
|
||
const AIChatLoggerExample = () => { | ||
const [templateIdx, setTemplateIdx] = React.useState(2); | ||
const { aiChats, push, pop, clear } = useAIChatLogger( | ||
aiChatFactory(chatTemplates[0]), | ||
aiChatFactory(chatTemplates[1]) | ||
); | ||
const [loading, setLoading] = React.useState(false); | ||
|
||
const pushChat = () => { | ||
const template = chatTemplates[templateIdx]; | ||
setTemplateIdx((idx) => ++idx % chatTemplates.length); | ||
const chat = aiChatFactory(template); | ||
|
||
if (template[1] === "bot") { | ||
const id = uid(chat.content); | ||
setLoading(true); | ||
push({ | ||
id, | ||
variant: template[1], | ||
content: ( | ||
<AIChatMessage variant="bot"> | ||
<AIChatMessageAuthor aria-label="AI said">Good Bot</AIChatMessageAuthor> | ||
<AIChatMessageBody> | ||
<AIChatMessageLoading /> | ||
</AIChatMessageBody> | ||
</AIChatMessage> | ||
), | ||
}); | ||
setTimeout(() => { | ||
pop(id); | ||
setLoading(false); | ||
push(chat); | ||
}, 1000); | ||
} else { | ||
push(chat); | ||
} | ||
} | ||
|
||
const popChat = () => { | ||
pop(); | ||
setTemplateIdx((idx) => idx === 0 ? idx : --idx % chatTemplates.length); | ||
} | ||
|
||
return( | ||
<Stack orientation="vertical"> | ||
<ButtonGroup> | ||
<Button variant="primary" disabled={loading} onClick={pushChat}> | ||
Push Chat | ||
</Button> | ||
<Button variant="primary" disabled={loading} onClick={popChat}> | ||
Pop Chat | ||
</Button> | ||
<Button variant="primary" disabled={loading} onClick={clear}> | ||
Clear Chat | ||
</Button> | ||
</ButtonGroup> | ||
<AIChatLogger aiChats={aiChats} /> | ||
</Stack> | ||
) | ||
} | ||
|
||
render(<AIChatLoggerExample />); | ||
`.trim(); | ||
export const avatarExample = ` | ||
const AvatarExample = () => { | ||
return ( | ||
<AIChatLog> | ||
<AIChatMessage variant="user"> | ||
<AIChatMessageAuthor avatarIcon={LogoTwilioIcon} aria-label="You said">Gibby Radki</AIChatMessageAuthor> | ||
</AIChatMessage> | ||
<AIChatMessage variant="user"> | ||
<AIChatMessageAuthor avatarSrc={Logo.src} aria-label="You said">Gibby Radki</AIChatMessageAuthor> | ||
</AIChatMessage> | ||
</AIChatLog> | ||
); | ||
}; | ||
|
||
render( | ||
<AvatarExample /> | ||
)`.trim(); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
niceeee