atgctg
atgctg
Explore posts from servers
CDCloudflare Developers
Created by atgctg on 7/14/2023 in #workers-help
Would Cloudflare Websockets work with a Next.js + tRPC project hosted on Pages?
6 replies
PD🧩 Plasmo Developers
Created by atgctg on 7/4/2023 in #👾extension
Can't import useChat from Vercel's AI SDK
Fails on a new project as well.
🔴 ERROR | Failed to resolve 'ai/react' from './popup.tsx'
🔴 ERROR | Cannot load file './react' from module 'ai'
🔴 ERROR | Failed to resolve 'ai/react' from './popup.tsx'
🔴 ERROR | Cannot load file './react' from module 'ai'
popup.tsx:
import { useChat } from "ai/react"

export default function Chat() {
const { messages, input, handleInputChange, handleSubmit } = useChat()

return (
<div className="mx-auto w-full max-w-md py-24 flex flex-col stretch">
{messages.map((m) => (
<div key={m.id}>
{m.role === "user" ? "User: " : "AI: "}
{m.content}
</div>
))}

<form onSubmit={handleSubmit}>
<label>
Say something...
<input
className="fixed w-full max-w-md bottom-0 border border-gray-300 rounded mb-8 shadow-xl p-2"
value={input}
onChange={handleInputChange}
/>
</label>
<button type="submit">Send</button>
</form>
</div>
)
}
import { useChat } from "ai/react"

export default function Chat() {
const { messages, input, handleInputChange, handleSubmit } = useChat()

return (
<div className="mx-auto w-full max-w-md py-24 flex flex-col stretch">
{messages.map((m) => (
<div key={m.id}>
{m.role === "user" ? "User: " : "AI: "}
{m.content}
</div>
))}

<form onSubmit={handleSubmit}>
<label>
Say something...
<input
className="fixed w-full max-w-md bottom-0 border border-gray-300 rounded mb-8 shadow-xl p-2"
value={input}
onChange={handleInputChange}
/>
</label>
<button type="submit">Send</button>
</form>
</div>
)
}
10 replies