mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-16 05:01:03 +03:00
feat(ai): add the xAI video entrypoint and keep video provider options (#63707)
This commit is contained in:
committed by
GitHub
Unverified
parent
73abe63ac2
commit
3518013b18
@@ -136,6 +136,7 @@
|
||||
"./providers/vercel-ai-gateway/responses": "./src/providers/vercel-ai-gateway/responses.ts",
|
||||
"./providers/xai": "./src/providers/xai.ts",
|
||||
"./providers/xai/images": "./src/providers/xai/images.ts",
|
||||
"./providers/xai/videos": "./src/providers/xai/videos.ts",
|
||||
"./providers/zai": "./src/providers/zai.ts",
|
||||
"./providers/zai-coding-plan": "./src/providers/zai-coding-plan.ts",
|
||||
"./providers/zai-coding-plan/chat": "./src/providers/zai-coding-plan/chat.ts",
|
||||
|
||||
@@ -74,7 +74,8 @@ export const configure = (input: Config = {}) => {
|
||||
interactionsRoute(input).model<GoogleInteractions.ProviderOptionsInput>({ id: modelID }),
|
||||
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) =>
|
||||
GoogleImages.model({ ...media, id: modelID, providerOptions }),
|
||||
video: (modelID: string | ModelID) => GoogleInteractionsVideo.model({ ...media, id: modelID }),
|
||||
video: (modelID: string | ModelID, providerOptions?: ProviderOptions) =>
|
||||
GoogleInteractionsVideo.model({ ...media, id: modelID, providerOptions }),
|
||||
speech: (modelID: string | ModelID) => GoogleSpeech.model({ ...media, id: modelID }),
|
||||
transcription: (modelID: string | ModelID) => GoogleTranscription.model({ ...media, id: modelID }),
|
||||
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) =>
|
||||
@@ -94,7 +95,10 @@ export const imageModel = (modelID: string, settings?: Settings) => {
|
||||
const input = toConfig(settings)
|
||||
return configure(input).image(modelID, input.providerOptions)
|
||||
}
|
||||
export const videoModel = (modelID: string, settings?: Settings) => configure(toConfig(settings)).video(modelID)
|
||||
export const videoModel = (modelID: string, settings?: Settings) => {
|
||||
const input = toConfig(settings)
|
||||
return configure(input).video(modelID, input.providerOptions)
|
||||
}
|
||||
export const embeddingModel = (modelID: string, settings?: Settings) => {
|
||||
const input = toConfig(settings)
|
||||
return configure(input).embedding(modelID, input.providerOptions)
|
||||
|
||||
@@ -100,7 +100,8 @@ export const configure = (input: Config = {}) => {
|
||||
chat,
|
||||
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) =>
|
||||
XAIImages.model({ ...media, id: modelID, providerOptions }),
|
||||
video: (modelID: string | ModelID) => XAIVideo.model({ ...media, id: modelID }),
|
||||
video: (modelID: string | ModelID, providerOptions?: ProviderOptions) =>
|
||||
XAIVideo.model({ ...media, id: modelID, providerOptions }),
|
||||
configure,
|
||||
}
|
||||
}
|
||||
@@ -114,6 +115,10 @@ export const imageModel = (modelID: string, settings?: Settings) => {
|
||||
const input = toConfig(settings)
|
||||
return configure(input).image(modelID, input.providerOptions)
|
||||
}
|
||||
export const videoModel = (modelID: string, settings?: Settings) => {
|
||||
const input = toConfig(settings)
|
||||
return configure(input).video(modelID, input.providerOptions)
|
||||
}
|
||||
export const responses = provider.responses
|
||||
export const chat = provider.chat
|
||||
export const image = provider.image
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
export { videoModel as model } from "../xai.js"
|
||||
export type { Settings } from "../xai.js"
|
||||
@@ -561,6 +561,15 @@ const videos: ReadonlyArray<Case<VideoModel>> = [
|
||||
auth: ["x-goog-api-key", "google-key"],
|
||||
provider: "google",
|
||||
},
|
||||
{
|
||||
name: "xai",
|
||||
load: async () => {
|
||||
const { model } = await import("@opencode/ai/providers/xai/videos")
|
||||
return model("grok-imagine-video-1.5", { ...shared, apiKey: "xai-key" })
|
||||
},
|
||||
url: "https://api.x.ai/v1/videos/generations",
|
||||
auth: ["authorization", "Bearer xai-key"],
|
||||
},
|
||||
]
|
||||
|
||||
describe("video entrypoints", () => {
|
||||
@@ -573,6 +582,21 @@ describe("video entrypoints", () => {
|
||||
)
|
||||
})
|
||||
|
||||
describe("video entrypoint model options", () => {
|
||||
// Model-level options from settings (as models.dev or config set them) become defaults on every request.
|
||||
for (const entry of [
|
||||
{ name: "xai", modelID: "grok-imagine-video-1.5", load: () => import("@opencode/ai/providers/xai/videos") },
|
||||
{ name: "google", modelID: "gemini-omni-1.2-flash", load: () => import("@opencode/ai/providers/google/videos") },
|
||||
])
|
||||
it.effect(`providers/${entry.name}/videos keeps provider options from settings`, () =>
|
||||
Effect.gen(function* () {
|
||||
const { model } = yield* Effect.promise(entry.load)
|
||||
const calls = yield* sentVideo(model(entry.modelID, { apiKey: "key", future_option: true }))
|
||||
expect(JSON.parse(calls[0].body).future_option).toBe(true)
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
describe("decision entrypoints", () => {
|
||||
for (const entry of decisions)
|
||||
it.effect(`providers/${entry.name}/decisions sends a configured request`, () =>
|
||||
|
||||
@@ -180,6 +180,7 @@ const builtins = new Map<string, () => Promise<unknown>>([
|
||||
],
|
||||
["@opencode/ai/providers/xai", () => import("@opencode/ai/providers/xai")],
|
||||
["@opencode/ai/providers/xai/images", () => import("@opencode/ai/providers/xai/images")],
|
||||
["@opencode/ai/providers/xai/videos", () => import("@opencode/ai/providers/xai/videos")],
|
||||
["@opencode/ai/providers/zai", () => import("@opencode/ai/providers/zai")],
|
||||
["@opencode/ai/providers/zai/chat", () => import("@opencode/ai/providers/zai/chat")],
|
||||
["@opencode/ai/providers/zai/images", () => import("@opencode/ai/providers/zai/images")],
|
||||
|
||||
Reference in New Issue
Block a user