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 (ui): refactorings & README update #3676

Merged
merged 2 commits into from
Nov 14, 2024
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
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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we can release the recent changes

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
Loading