fix(opencode): update xai provider
This commit is contained in:
parent
f9ba23ab62
commit
67223eaa53
7 changed files with 144 additions and 107 deletions
|
|
@ -54,7 +54,7 @@
|
|||
"@ai-sdk/provider-utils": "4.0.23",
|
||||
"@ai-sdk/togetherai": "2.0.41",
|
||||
"@ai-sdk/vercel": "2.0.39",
|
||||
"@ai-sdk/xai": "3.0.82",
|
||||
"@ai-sdk/xai": "3.0.92",
|
||||
"@aws-sdk/credential-providers": "3.993.0",
|
||||
"@effect/opentelemetry": "catalog:",
|
||||
"@effect/platform-node": "catalog:",
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@
|
|||
"@ai-sdk/provider": "3.0.8",
|
||||
"@ai-sdk/togetherai": "2.0.41",
|
||||
"@ai-sdk/vercel": "2.0.39",
|
||||
"@ai-sdk/xai": "3.0.82",
|
||||
"@ai-sdk/xai": "3.0.92",
|
||||
"@aws-sdk/credential-providers": "3.993.0",
|
||||
"@clack/prompts": "1.0.0-alpha.1",
|
||||
"@effect/opentelemetry": "catalog:",
|
||||
|
|
|
|||
53
packages/opencode/test/provider/xai.test.ts
Normal file
53
packages/opencode/test/provider/xai.test.ts
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import { describe, expect, test } from "bun:test"
|
||||
import { createXai } from "@ai-sdk/xai"
|
||||
|
||||
describe("@ai-sdk/xai", () => {
|
||||
test("sends inline PDF attachments through the Responses API", async () => {
|
||||
let input: unknown
|
||||
const handle = async (_url: Parameters<typeof fetch>[0], options?: Parameters<typeof fetch>[1]) => {
|
||||
input = JSON.parse(String(options?.body)).input
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
object: "response",
|
||||
output: [],
|
||||
status: "completed",
|
||||
usage: { input_tokens: 0, output_tokens: 0 },
|
||||
}),
|
||||
{ status: 200, headers: { "content-type": "application/json" } },
|
||||
)
|
||||
}
|
||||
const xai = createXai({
|
||||
apiKey: "test",
|
||||
fetch: Object.assign(handle, { preconnect: fetch.preconnect.bind(fetch) }),
|
||||
})
|
||||
|
||||
await xai.responses("grok-4").doGenerate({
|
||||
prompt: [
|
||||
{
|
||||
role: "user",
|
||||
content: [
|
||||
{
|
||||
type: "file",
|
||||
mediaType: "application/pdf",
|
||||
filename: "sample.pdf",
|
||||
data: new Uint8Array([0x25, 0x50, 0x44, 0x46]),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
expect(input).toEqual([
|
||||
{
|
||||
role: "user",
|
||||
content: [
|
||||
{
|
||||
type: "input_file",
|
||||
filename: "sample.pdf",
|
||||
file_data: "data:application/pdf;base64,JVBERg==",
|
||||
},
|
||||
],
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue