-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ai-chat-log): Adding docs for new component (#3963)
* chore: checkpoint ai log and ai msg * chore: checkpoint * chore: checkpoint more progress * chore: typo fix * chore: wip working useAILogger * feat: message typewriter component * chore: working typewriter * chore: name cleanup and JSDoc * chore: lint updates * chore: chageset * chore: fix lint & build * chore: build update * chore: yarn update * chore: cleanup, renaming, small refactors * chore(docs): ai chat log init * chore(docs): functional init * chore(docs): new sections complete with examples * chore(docs): wip * chore(docs): update package decription * chore(docs): chat log typo * chore(docs): renaming for enw imports and AIChatLogger example * chore(docs): loading notes and removal of action buttons * chore(docs): reference other type of ChatLog * chore: checkpoint ai log and ai msg * chore: checkpoint * chore: checkpoint more progress * chore: typo fix * chore: wip working useAILogger * feat: message typewriter component * chore: working typewriter * chore: name cleanup and JSDoc * chore: lint updates * chore: chageset * chore: fix lint & build * chore: build update * chore: yarn update * chore: cleanup, renaming, small refactors * chore: animations * chore: refactors renaming and composer story * feat(button): allow `pressed` on reset buttons * test: add tests and update stories * chore: type docs * chore: codemods changeset * chore(docs): ai logs update * chore(docs): ui logs update * chore(docs): revert flex test * chore(docs): ia logs update * chore(button): undo toggle reset change and add border radius to reset * chore(button-group): flex unattached groups * chore: actioin card changes from huddle * chore: update all stories with changes * chore: typedocs * chore(docs): update action card naming * chore(docs): cleanup PR * chore(docs): add vrt for new docs pages * feat(docs): update imports * feat(docs): updated imports * chore(docs): add dependency * chore(docs): update lock file * chore(docs): update descprition * chore(docs): typo fix * feat(docs/ai): address PR comments * feat(docs/ai): move buttons to next line * Apply suggestions from code review Co-authored-by: Sarah <[email protected]> --------- Co-authored-by: TheSisb <[email protected]> Co-authored-by: Nora Krantz <[email protected]> Co-authored-by: “nora <[email protected]> Co-authored-by: Sarah <[email protected]>
- Loading branch information
1 parent
b5e6d3f
commit 5558496
Showing
12 changed files
with
835 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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.