-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Closed
Description
Description
When I use the perplexity/sonar-reasoning-pro model or any Perplexity reasoning model via the Vercel API Gateway and try to generate an object:
the response content from Perplexity seems to not be properly handled, and as such the object fails to be parsed.
Here's the error:
Error message: Unexpected token '<', "<think>
Le"... is not valid JSON
cause: [SyntaxError: Unexpected token '<', "<think>
Le"... is not valid JSON],
Here's the output text (most of the thinking was omitted):
'<think>\n' +
'Let me analyze the task carefully. I need to:\n' +
'\n' +
"1. Go to company websites' careers/jobs pages\n" +
'</think>\n' +
'\n' +
`{"valid": false, "reasons": ["omitted"]}`,Here's how I'm trying to generate the object:
import { generateText, Output } from "ai";
import { z } from "zod";
const result = await generateText({
model: "perplexity/sonar-reasoning-pro",
system: config.systemPrompt,
prompt: `Evaluate this company: "${companyName}."`,
output: Output.object({
schema: z.object({
valid: z
.boolean(),
reasons: z
.array(z.string())
.nullable(),
}),
}),
});
console.log(result.output);AI SDK Version
- ai: 6.0.5
Code of Conduct
- I agree to follow this project's Code of Conduct
Reactions are currently unavailable