Skip to content

Commit

Permalink
chore (ui): refactorings & README update (#3676)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrammel authored Nov 14, 2024
1 parent 343c106 commit b053413
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
6 changes: 6 additions & 0 deletions .changeset/wise-geese-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'ai': patch
'@ai-sdk/ui-utils': patch
---

chore (ui): refactorings & README update
22 changes: 9 additions & 13 deletions packages/ai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,13 @@ npm install @ai-sdk/openai
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai'; // Ensure OPENAI_API_KEY environment variable is set

async function main() {
const { text } = await generateText({
model: openai('gpt-4-turbo'),
system: 'You are a friendly assistant!',
prompt: 'Why is the sky blue?',
});

console.log(text);
}
const { text } = await generateText({
model: openai('gpt-4o'),
system: 'You are a friendly assistant!',
prompt: 'Why is the sky blue?',
});

main();
console.log(text);
```

### AI SDK UI
Expand Down Expand Up @@ -85,14 +81,14 @@ export default function Page() {
###### @/app/api/chat/route.ts (Next.js App Router)

```ts
import { CoreMessage, streamText } from 'ai';
import { streamText } from 'ai';
import { openai } from '@ai-sdk/openai';

export async function POST(req: Request) {
const { messages }: { messages: CoreMessage[] } = await req.json();
const { messages } = await req.json();

const result = streamText({
model: openai('gpt-4'),
model: openai('gpt-4o'),
system: 'You are a helpful assistant.',
messages,
});
Expand Down

0 comments on commit b053413

Please sign in to comment.