Skip to content

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 72 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 69 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 Apr 24, 2024
5c21b5b
chore: checkpoint
TheSisb May 9, 2024
6a8f9de
chore: checkpoint more progress
TheSisb May 17, 2024
e4984c3
Merge branch 'main' of github.com:twilio-labs/paste into ai-kit/logs-v2
krisantrobus May 29, 2024
f51a267
chore: typo fix
krisantrobus May 29, 2024
e0fffdf
chore: wip working useAILogger
krisantrobus May 31, 2024
8437c06
feat: message typewriter component
krisantrobus May 31, 2024
b35952f
chore: working typewriter
krisantrobus May 31, 2024
6fe0f56
chore: name cleanup and JSDoc
krisantrobus May 31, 2024
bb64b73
chore: lint updates
krisantrobus May 31, 2024
a7d924f
chore: chageset
krisantrobus May 31, 2024
5ee7cf4
chore: fix lint & build
krisantrobus May 31, 2024
925fd0a
chore: build update
krisantrobus May 31, 2024
9cb001a
chore: yarn update
krisantrobus May 31, 2024
2d941d0
Merge branch 'main' into ai-kit/logs-v2
nkrantz Jun 10, 2024
9dcf2db
chore: cleanup, renaming, small refactors
nkrantz Jun 10, 2024
6e627ec
chore(docs): ai chat log init
krisantrobus Jun 11, 2024
9da6bcf
chore(docs): functional init
krisantrobus Jun 11, 2024
6bdfff2
chore(docs): new sections complete with examples
krisantrobus Jun 12, 2024
64b9cfd
chore(docs): wip
krisantrobus Jun 12, 2024
b210d2c
chore(docs): merge branch 'ai-kit/logs-v2' of github.com:twilio-labs/…
krisantrobus Jun 12, 2024
0407ea3
chore(docs): update package decription
krisantrobus Jun 12, 2024
ba59388
chore(docs): chat log typo
krisantrobus Jun 12, 2024
ab9835e
chore(docs): renaming for enw imports and AIChatLogger example
krisantrobus Jun 12, 2024
369cad7
chore(docs): loading notes and removal of action buttons
krisantrobus Jun 12, 2024
2c6d0a2
chore(docs): reference other type of ChatLog
krisantrobus Jun 12, 2024
173a752
chore: checkpoint ai log and ai msg
TheSisb Apr 24, 2024
90310f2
chore: checkpoint
TheSisb May 9, 2024
fe3e6bb
chore: checkpoint more progress
TheSisb May 17, 2024
26de793
chore: typo fix
krisantrobus May 29, 2024
0f27f00
chore: wip working useAILogger
krisantrobus May 31, 2024
3f6fff4
feat: message typewriter component
krisantrobus May 31, 2024
b1b8bed
chore: working typewriter
krisantrobus May 31, 2024
2da7c1a
chore: name cleanup and JSDoc
krisantrobus May 31, 2024
86c31f3
chore: lint updates
krisantrobus May 31, 2024
2d05ede
chore: chageset
krisantrobus May 31, 2024
954b8a8
chore: fix lint & build
krisantrobus May 31, 2024
9f64266
chore: build update
krisantrobus May 31, 2024
ccaa288
chore: yarn update
krisantrobus May 31, 2024
dcf1a75
chore: cleanup, renaming, small refactors
nkrantz Jun 10, 2024
3346998
chore: animations
nkrantz Jun 11, 2024
3b07554
chore: refactors renaming and composer story
nkrantz Jun 13, 2024
9baedf4
feat(button): allow `pressed` on reset buttons
nkrantz Jun 13, 2024
7584fde
test: add tests and update stories
nkrantz Jun 13, 2024
c7c914e
chore: type docs
nkrantz Jun 13, 2024
dab49e1
chore: codemods changeset
nkrantz Jun 13, 2024
5cfe884
chore(docs): merge branch 'ai-kit/logs-v2' of github.com:twilio-labs/…
krisantrobus Jun 14, 2024
f1b742c
chore(docs): ai logs update
krisantrobus Jun 14, 2024
53bae02
chore(docs): ui logs update
krisantrobus Jun 14, 2024
a670e5f
chore(docs): revert flex test
krisantrobus Jun 14, 2024
4d91f51
chore(docs): ia logs update
krisantrobus Jun 14, 2024
3b9fa3f
chore(button): undo toggle reset change and add border radius to reset
nkrantz Jun 15, 2024
755d8d9
chore(button-group): flex unattached groups
nkrantz Jun 15, 2024
e61f918
chore: actioin card changes from huddle
nkrantz Jun 15, 2024
3580d95
chore: update all stories with changes
nkrantz Jun 15, 2024
94a4000
chore: typedocs
nkrantz Jun 15, 2024
de58ef1
Merge branch 'ai-kit/logs-v2' of github.com:twilio-labs/paste into do…
krisantrobus Jun 17, 2024
3fb49a3
chore(docs): update action card naming
krisantrobus Jun 17, 2024
29f68f9
chore(docs): cleanup PR
krisantrobus Jun 17, 2024
634fabe
chore(docs): add vrt for new docs pages
krisantrobus Jun 17, 2024
732f39b
chore(docs): merge branch 'main' of github.com:twilio-labs/paste into…
krisantrobus Jun 18, 2024
207c3fb
Merge branch 'main' of github.com:twilio-labs/paste into docs/ai-logs
krisantrobus Jun 20, 2024
dede25f
feat(docs): update imports
krisantrobus Jun 25, 2024
a06a129
feat(docs): updated imports
krisantrobus Jun 25, 2024
ce5e32b
chore(docs): add dependency
krisantrobus Jun 25, 2024
107797f
chore(docs): update lock file
krisantrobus Jun 25, 2024
5dd1810
chore(docs): update descprition
krisantrobus Jun 25, 2024
69a5a15
chore(docs): typo fix
krisantrobus Jun 25, 2024
c06291e
Merge branch 'main' of github.com:twilio-labs/paste into docs/ai-log-2
krisantrobus Jun 25, 2024
fbe0c69
feat(docs/ai): address PR comments
krisantrobus Jun 27, 2024
deddcdd
feat(docs/ai): move buttons to next line
krisantrobus Jun 27, 2024
9e7f85e
Apply suggestions from code review
krisantrobus Jul 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/pretty-melons-punch.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"@twilio-paste/core": patch
---

[Button] Add border radius 20 to size="reset" buttons which can be overridden by passing a border radius token to variant="reset" and size="reset" buttons
[Button] Add border radius 20 to size="reset" buttons which can be overridden by passing a border radius token to variant="reset" and size="reset" buttons
3 changes: 3 additions & 0 deletions cypress/integration/sitemap-vrt/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export const SITEMAP = [
"/components/account-switcher/",
"/components/account-switcher/api",
"/components/account-switcher/changelog",
"/components/ai-chat-log/",
"/components/ai-chat-log/api",
"/components/ai-chat-log/changelog",
"/components/aspect-ratio/",
"/components/aspect-ratio/api",
"/components/aspect-ratio/changelog",
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion packages/paste-core/components/ai-chat-log/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"category": "data display",
"status": "production",
"description": "Ai chat log.",
"description": "An AI Chat Log is a collection of AI Chat components for displaying conversations between a human and an AI bot.",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

niceeee

"author": "Twilio Inc.",
"license": "MIT",
"main:dev": "src/index.tsx",
Expand Down
1 change: 1 addition & 0 deletions packages/paste-website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@tanstack/react-query": "^5.17.9",
"@tanstack/react-query-devtools": "^5.17.10",
"@twilio-paste/account-switcher": "^3.0.1",
"@twilio-paste/ai-chat-log": "^0.0.0",
"@twilio-paste/alert": "^14.1.0",
"@twilio-paste/alert-dialog": "^9.2.0",
"@twilio-paste/anchor": "^12.1.0",
Expand Down
302 changes: 302 additions & 0 deletions packages/paste-website/src/component-examples/AIChatLogExamples.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,302 @@
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 aria-label="Feedback form">
<AIChatMessageActionCard>
Is this helpful?
<Button variant="reset" size="reset">
<ThumbsUpIcon decorative={false} title="like result" />
</Button>
<Button variant="reset" size="reset">
<ThumbsDownIcon decorative={false} title="dislike result" />
</Button>
</AIChatMessageActionCard>
<AIChatMessageActionCard>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: I think I added some aria labels to the rewrite button and maybe also the thumbs up/down buttons in the stories - can you copy whatever I did there for the action card sections in these examples?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch. I will address this in the next commit

<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>
Below is a list of actions that can be taken with flex wrapping supported:
<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>
<Button variant="secondary" size="rounded_small" onClick={() => {}}>
Access Documentation
</Button>
<Button variant="secondary" size="rounded_small" onClick={() => {}}>
Contact Support
</Button>
<Button variant="secondary" size="rounded_small" onClick={() => {}}>
Enable Debug Mode
</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>
Error codes can be returned from various parts of the process. What error codes are you encountering?
<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 aria-label="Feedback form">
<AIChatMessageActionCard>
Is this helpful?
<Button variant="reset" size="reset">
<ThumbsUpIcon decorative={false} title="like result" />
</Button>
<Button variant="reset" size="reset">
<ThumbsDownIcon decorative={false} title="dislike result" />
</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();
Loading
Loading