feat(ai): type Vertex request options (#39499)
This commit is contained in:
parent
d72b428061
commit
9554f9a16e
2 changed files with 23 additions and 2 deletions
|
|
@ -77,7 +77,8 @@ const configuredRoute = (input: Config, modelID: string | ModelID) => {
|
||||||
export const configure = (input: Config = {}) => {
|
export const configure = (input: Config = {}) => {
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
model: (modelID: string | ModelID) => configuredRoute(input, modelID).model({ id: modelID }),
|
model: (modelID: string | ModelID) =>
|
||||||
|
configuredRoute(input, modelID).model<Gemini.ProviderOptionsInput>({ id: modelID }),
|
||||||
configure,
|
configure,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -86,7 +87,10 @@ export const provider = {
|
||||||
id,
|
id,
|
||||||
configure,
|
configure,
|
||||||
}
|
}
|
||||||
export const model: ProviderPackage.Definition<Settings>["model"] = (modelID, settings) => {
|
export const model: ProviderPackage.Definition<Settings, Gemini.ProviderOptionsInput>["model"] = (
|
||||||
|
modelID,
|
||||||
|
settings,
|
||||||
|
) => {
|
||||||
if (settings.apiKey !== undefined && settings.accessToken !== undefined)
|
if (settings.apiKey !== undefined && settings.accessToken !== undefined)
|
||||||
throw new Error("Google Vertex apiKey cannot be combined with accessToken or auth")
|
throw new Error("Google Vertex apiKey cannot be combined with accessToken or auth")
|
||||||
return configure({
|
return configure({
|
||||||
|
|
|
||||||
17
packages/ai/test/provider-options/google-vertex.types.ts
Normal file
17
packages/ai/test/provider-options/google-vertex.types.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { LLM } from "../../src"
|
||||||
|
import { GoogleVertex } from "../../src/providers"
|
||||||
|
|
||||||
|
const model = GoogleVertex.provider.configure({ apiKey: "test" }).model("gemini-2.5-pro")
|
||||||
|
|
||||||
|
LLM.request({
|
||||||
|
model,
|
||||||
|
prompt: "Hello",
|
||||||
|
providerOptions: { gemini: { thinkingConfig: { includeThoughts: true } } },
|
||||||
|
})
|
||||||
|
|
||||||
|
LLM.request({
|
||||||
|
model,
|
||||||
|
prompt: "Hello",
|
||||||
|
// @ts-expect-error Vertex Gemini includeThoughts must be boolean.
|
||||||
|
providerOptions: { gemini: { thinkingConfig: { includeThoughts: "yes" } } },
|
||||||
|
})
|
||||||
Loading…
Add table
Add a link
Reference in a new issue