-
Notifications
You must be signed in to change notification settings - Fork 119
chore(assistant): use ai components #4112
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 all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
629854a
chore: 1
nkrantz ce3047e
chore: 2
nkrantz 360cf9d
chore: 3
nkrantz aea8d33
chore: 4
nkrantz c882f4c
chore: 5
nkrantz 383b21e
chore: 6
nkrantz aec9b4d
chore: 7
nkrantz b6fd6fa
chore: 8
nkrantz 0ba3a34
chore: 9
nkrantz 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
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
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
20 changes: 8 additions & 12 deletions
20
packages/paste-website/src/components/assistant/AssistantMessage.tsx
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 |
---|---|---|
@@ -1,25 +1,21 @@ | ||
import { ChatBubble, ChatMessage, ChatMessageMeta, ChatMessageMetaItem } from "@twilio-paste/chat-log"; | ||
import { AIChatMessage, AIChatMessageAuthor, AIChatMessageBody } from "@twilio-paste/ai-chat-log"; | ||
import { type ThreadMessage } from "openai/resources/beta/threads/messages"; | ||
import * as React from "react"; | ||
|
||
import { Logo } from "../../assets/Logo"; | ||
import { formatTimestamp } from "../../utils/formatTimestamp"; | ||
import { AssistantMarkdown } from "./AssistantMarkdown"; | ||
|
||
export const AssistantMessage: React.FC<{ threadMessage: ThreadMessage }> = ({ threadMessage }) => { | ||
return ( | ||
<ChatMessage variant="inbound"> | ||
<ChatBubble> | ||
<AIChatMessage variant="bot"> | ||
<AIChatMessageAuthor aria-label={`said by paste assistant at ${formatTimestamp(threadMessage.created_at)}`}> | ||
PasteBot | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great aria-label! |
||
</AIChatMessageAuthor> | ||
<AIChatMessageBody> | ||
{threadMessage.content[0].type === "text" && ( | ||
<AssistantMarkdown key={threadMessage.id}>{threadMessage.content[0].text.value}</AssistantMarkdown> | ||
)} | ||
</ChatBubble> | ||
<ChatMessageMeta aria-label={`said by the assistant at ${formatTimestamp(threadMessage.created_at)}`}> | ||
<ChatMessageMetaItem> | ||
<Logo size={20} /> | ||
PasteBot ・ {formatTimestamp(threadMessage.created_at)} | ||
</ChatMessageMetaItem> | ||
</ChatMessageMeta> | ||
</ChatMessage> | ||
</AIChatMessageBody> | ||
</AIChatMessage> | ||
); | ||
}; |
11 changes: 0 additions & 11 deletions
11
packages/paste-website/src/components/assistant/FocusComposerPlugin.tsx
This file was deleted.
Oops, something went wrong.
55 changes: 10 additions & 45 deletions
55
packages/paste-website/src/components/assistant/LoadingMessage.tsx
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 |
---|---|---|
@@ -1,55 +1,20 @@ | ||
/* eslint-disable camelcase */ | ||
import { Box } from "@twilio-paste/box"; | ||
import { ChatBubble, ChatMessage, ChatMessageMeta, ChatMessageMetaItem } from "@twilio-paste/chat-log"; | ||
import { SkeletonLoader } from "@twilio-paste/skeleton-loader"; | ||
import { useUID } from "@twilio-paste/uid-library"; | ||
import { AIChatMessage, AIChatMessageAuthor, AIChatMessageBody, AIChatMessageLoading } from "@twilio-paste/ai-chat-log"; | ||
import * as React from "react"; | ||
|
||
import { Logo } from "../../assets/Logo"; | ||
import { useAssistantRunStore } from "../../stores/assistantRunStore"; | ||
import { formatTimestamp } from "../../utils/formatTimestamp"; | ||
|
||
const getRandomNumber = (max: number): number => { | ||
return Math.floor(Math.random() * max); | ||
}; | ||
|
||
const STATUS_MAP = { | ||
queued: "Queued...", | ||
in_progress: "Researching...", | ||
requires_action: "Researching...", | ||
cancelling: "Concelling...", | ||
cancelled: "Cancelled.", | ||
failed: "Failed.", | ||
completed: "Finished.", | ||
expired: "Expired.", | ||
}; | ||
|
||
export const LoadingMessage: React.FC<{ maxWidth: number }> = ({ maxWidth }) => { | ||
const activeRun = useAssistantRunStore((state) => state.activeRun); | ||
|
||
export const LoadingMessage: React.FC = () => { | ||
const newDateTime = new Date(); | ||
const timestamp = Math.floor(newDateTime.getTime() / 1000); | ||
|
||
const randomWidths = React.useMemo(() => { | ||
return Array.from({ length: 3 }, () => getRandomNumber(maxWidth)); | ||
}, [maxWidth]); | ||
|
||
return ( | ||
<ChatMessage variant="inbound"> | ||
<ChatBubble> | ||
<Box display="grid" rowGap="space30"> | ||
{randomWidths.map((width) => ( | ||
<SkeletonLoader key={useUID()} height="20px" width={`${width}px`} /> | ||
))} | ||
</Box> | ||
</ChatBubble> | ||
<ChatMessageMeta aria-label={`said by the assistant at ${formatTimestamp(timestamp)}`}> | ||
<ChatMessageMetaItem> | ||
<Logo size={20} /> | ||
PasteBot ・ {activeRun?.status ? STATUS_MAP[activeRun?.status] : "Thinking..."} | ||
</ChatMessageMetaItem> | ||
</ChatMessageMeta> | ||
</ChatMessage> | ||
<AIChatMessage variant="bot"> | ||
<AIChatMessageAuthor aria-label={`said by paste assistant at ${formatTimestamp(timestamp)}`}> | ||
PasteBot | ||
</AIChatMessageAuthor> | ||
<AIChatMessageBody> | ||
<AIChatMessageLoading /> | ||
</AIChatMessageBody> | ||
</AIChatMessage> | ||
); | ||
}; | ||
/* eslint-enable camelcase */ |
21 changes: 0 additions & 21 deletions
21
packages/paste-website/src/components/assistant/SendButtonPlugin.tsx
This file was deleted.
Oops, something went wrong.
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.
Yes new chat composer! 🤟