-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (ai/core): add system message support in messages list (#1551)
- Loading branch information
Showing
6 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@ai-sdk/anthropic': patch | ||
'ai': patch | ||
--- | ||
|
||
feat (ai/core): add system message support in messages list |
19 changes: 19 additions & 0 deletions
19
examples/ai-core/src/generate-text/openai-system-message-a.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { openai } from '@ai-sdk/openai'; | ||
import { generateText } from 'ai'; | ||
import dotenv from 'dotenv'; | ||
|
||
dotenv.config(); | ||
|
||
async function main() { | ||
const result = await generateText({ | ||
model: openai('gpt-3.5-turbo'), | ||
messages: [ | ||
{ role: 'system', content: 'You are a helpful assistant.' }, | ||
{ role: 'user', content: 'What is the capital of France?' }, | ||
], | ||
}); | ||
|
||
console.log(result.text); | ||
} | ||
|
||
main().catch(console.error); |
17 changes: 17 additions & 0 deletions
17
examples/ai-core/src/generate-text/openai-system-message-b.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { openai } from '@ai-sdk/openai'; | ||
import { generateText } from 'ai'; | ||
import dotenv from 'dotenv'; | ||
|
||
dotenv.config(); | ||
|
||
async function main() { | ||
const result = await generateText({ | ||
model: openai('gpt-3.5-turbo'), | ||
system: 'You are a helpful assistant.', | ||
messages: [{ role: 'user', content: 'What is the capital of France?' }], | ||
}); | ||
|
||
console.log(result.text); | ||
} | ||
|
||
main().catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters