Skip to content
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

chore (docs): cleanup classnames #4923

Merged
merged 1 commit into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 3 additions & 7 deletions content/docs/04-ai-sdk-ui/02-chatbot.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ On the client side, you can access the reasoning parts of the message object:

```tsx filename="app/page.tsx"
messages.map(message => (
<div key={message.id} className="whitespace-pre-wrap">
<div key={message.id}>
{message.role === 'user' ? 'User: ' : 'AI: '}
{message.parts.map((part, index) => {
// text parts:
Expand Down Expand Up @@ -576,7 +576,7 @@ Here is an example that renders the sources as links at the bottom of the messag

```tsx filename="app/page.tsx"
messages.map(message => (
<div key={message.id} className="whitespace-pre-wrap">
<div key={message.id}>
{message.role === 'user' ? 'User: ' : 'AI: '}
{message.parts
.filter(part => part.type !== 'source')
Expand All @@ -590,11 +590,7 @@ messages.map(message => (
.map(part => (
<span key={`source-${part.source.id}`}>
[
<a
href={part.source.url}
target="_blank"
className="text-sm font-bold text-blue-500 hover:underline"
>
<a href={part.source.url} target="_blank">
{part.source.title ?? new URL(part.source.url).hostname}
</a>
]
Expand Down
22 changes: 8 additions & 14 deletions content/docs/04-ai-sdk-ui/03-chatbot-tool-usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export default function Chat() {
return (
<>
{messages?.map(message => (
<div key={message.id} className="whitespace-pre-wrap">
<div key={message.id}>
<strong>{`${message.role}: `}</strong>
{message.parts.map(part => {
switch (part.type) {
Expand All @@ -159,11 +159,10 @@ export default function Chat() {
switch (part.toolInvocation.state) {
case 'call':
return (
<div key={callId} className="text-gray-500">
<div key={callId}>
{part.toolInvocation.args.message}
<div className="flex gap-2">
<div>
<button
className="px-4 py-2 font-bold text-white bg-blue-500 rounded hover:bg-blue-700"
onClick={() =>
addToolResult({
toolCallId: callId,
Expand All @@ -174,7 +173,6 @@ export default function Chat() {
Yes
</button>
<button
className="px-4 py-2 font-bold text-white bg-red-500 rounded hover:bg-red-700"
onClick={() =>
addToolResult({
toolCallId: callId,
Expand All @@ -189,7 +187,7 @@ export default function Chat() {
);
case 'result':
return (
<div key={callId} className="text-gray-500">
<div key={callId}>
Location access allowed:{' '}
{part.toolInvocation.result}
</div>
Expand All @@ -201,14 +199,10 @@ export default function Chat() {
case 'getLocation': {
switch (part.toolInvocation.state) {
case 'call':
return (
<div key={callId} className="text-gray-500">
Getting location...
</div>
);
return <div key={callId}>Getting location...</div>;
case 'result':
return (
<div key={callId} className="text-gray-500">
<div key={callId}>
Location: {part.toolInvocation.result}
</div>
);
Expand All @@ -227,14 +221,14 @@ export default function Chat() {
);
case 'call':
return (
<div key={callId} className="text-gray-500">
<div key={callId}>
Getting weather information for{' '}
{part.toolInvocation.args.city}...
</div>
);
case 'result':
return (
<div key={callId} className="text-gray-500">
<div key={callId}>
Weather in {part.toolInvocation.args.city}:{' '}
{part.toolInvocation.result}
</div>
Expand Down
Loading