-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (provider/perplexity): rewrite provider and support sources (#4864)
- Loading branch information
Showing
32 changed files
with
1,433 additions
and
621 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-sdk/perplexity': major | ||
--- | ||
|
||
feat (provider/perplexity): rewrite provider and support sources |
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/provider-utils': patch | ||
'ai': patch | ||
--- | ||
|
||
chore (ai): move mockId test helper into provider utils |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'dotenv/config'; | ||
import { perplexity } from '@ai-sdk/perplexity'; | ||
import { generateObject, generateText } from 'ai'; | ||
import { z } from 'zod'; | ||
|
||
async function main() { | ||
const result = await generateObject({ | ||
model: perplexity('sonar-pro'), | ||
prompt: 'What has happened in San Francisco recently?', | ||
providerOptions: { | ||
perplexity: { | ||
search_recency_filter: 'week', | ||
}, | ||
}, | ||
output: 'array', | ||
schema: z.object({ | ||
title: z.string(), | ||
summary: z.string(), | ||
}), | ||
}); | ||
|
||
console.log(result.object); | ||
console.log(); | ||
console.log('Token usage:', result.usage); | ||
console.log('Finish reason:', result.finishReason); | ||
console.log('Metadata:', result.providerMetadata); | ||
} | ||
|
||
main().catch((error: Error) => { | ||
console.error(JSON.stringify(error, null, 2)); | ||
}); |
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
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
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
2 changes: 1 addition & 1 deletion
2
packages/ai/core/middleware/extract-reasoning-middleware.test.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
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
28 changes: 28 additions & 0 deletions
28
packages/perplexity/src/__snapshots__/convert-to-perplexity-messages.test.ts.snap
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,28 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`convertToPerplexityMessages > assistant messages > should convert an assistant message with text content 1`] = ` | ||
[ | ||
{ | ||
"content": "Assistant reply", | ||
"role": "assistant", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`convertToPerplexityMessages > system messages > should convert a system message with text content 1`] = ` | ||
[ | ||
{ | ||
"content": "System initialization", | ||
"role": "system", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`convertToPerplexityMessages > user messages > should convert a user message with text parts 1`] = ` | ||
[ | ||
{ | ||
"content": "Hello World", | ||
"role": "user", | ||
}, | ||
] | ||
`; |
Oops, something went wrong.