'use client'; import AnthropicWebFetchView from '@/component/anthropic-web-fetch-view'; import ChatInput from '@/component/chat-input'; import { useChat } from '@ai-sdk/react'; import { DefaultChatTransport } from 'ai'; import { AnthropicWebFetchMessage } from '../api/anthropic-web-fetch/route'; export default function TestAnthropicWebFetch() { const { status, sendMessage, messages } = useChat({ transport: new DefaultChatTransport({ api: '/api/anthropic-web-fetch', }), }); return (

Anthropic Web Fetch Test

{messages.map(message => (
{message.role === 'user' ? 'User: ' : 'AI: '} {message.parts.map((part, index) => { if (part.type === 'text') { return
{part.text}
; } if (part.type === 'tool-web_fetch') { return ; } if (part.type === 'source-url') { return ( [ {part.title ?? new URL(part.url).hostname} ] ); } return null; })}
))} sendMessage({ text })} />
); }