-
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 continuationSteps to generateText (#3104)
- Loading branch information
Showing
7 changed files
with
460 additions
and
27 deletions.
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,5 @@ | ||
--- | ||
'ai': patch | ||
--- | ||
|
||
feat (ai/core): add continuationSteps to generateText |
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
23 changes: 23 additions & 0 deletions
23
examples/ai-core/src/generate-text/openai-multi-step-continuation.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,23 @@ | ||
import { openai } from '@ai-sdk/openai'; | ||
import { generateText } from 'ai'; | ||
import 'dotenv/config'; | ||
|
||
async function main() { | ||
const { text, usage, steps } = await generateText({ | ||
model: openai('gpt-4o'), // 4096 output tokens | ||
maxSteps: 5, | ||
experimental_continuationSteps: true, | ||
prompt: | ||
'Write a book about Roman history, ' + | ||
'from the founding of the city of Rome ' + | ||
'to the fall of the Western Roman Empire. ' + | ||
'Each chapter MUST HAVE at least 1000 words.', | ||
}); | ||
|
||
console.log(text); | ||
console.log(); | ||
console.log('Usage:', usage); | ||
console.log('# of steps:', steps.length); | ||
} | ||
|
||
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
Oops, something went wrong.