add optional headers field to model config (#3546)

This commit is contained in:
Filip
2025-10-31 05:35:26 +01:00
committed by GitHub
parent 43e272e6c4
commit 51e4c9fc4c
5 changed files with 11 additions and 3 deletions

View File

@@ -37,6 +37,7 @@ export namespace ModelsDev {
experimental: z.boolean().optional(),
status: z.enum(["alpha", "beta"]).optional(),
options: z.record(z.string(), z.any()),
headers: z.record(z.string(), z.string()).optional(),
provider: z.object({ npm: z.string() }).optional(),
})
.meta({

View File

@@ -306,6 +306,7 @@ export namespace Provider {
input: ["text"],
output: ["text"],
},
headers: model.headers,
provider: model.provider ?? existing?.provider,
}
if (model.id && model.id !== modelID) {

View File

@@ -150,6 +150,7 @@ export namespace SessionCompaction {
maxRetries: 0,
model: model.language,
providerOptions: ProviderTransform.providerOptions(model.npm, model.providerID, model.info.options),
headers: model.info.headers,
abortSignal: signal,
onError(error) {
log.error("stream error", {

View File

@@ -270,13 +270,15 @@ export namespace SessionPrompt {
toolName: "invalid",
}
},
headers:
model.providerID === "opencode"
headers: {
...(model.providerID === "opencode"
? {
"x-opencode-session": input.sessionID,
"x-opencode-request": userMsg.info.id,
}
: undefined,
: undefined),
...model.info.headers,
},
// set to 0, we handle loop
maxRetries: 0,
activeTools: Object.keys(tools).filter((x) => x !== "invalid"),
@@ -1816,6 +1818,7 @@ export namespace SessionPrompt {
},
]),
],
headers: small.info.headers,
model: small.language,
})
.then((result) => {

View File

@@ -84,6 +84,7 @@ export namespace SessionSummary {
content: textPart?.text ?? "",
},
],
headers:small.info.headers,
model: small.language,
})
log.info("title", { title: result.text })
@@ -116,6 +117,7 @@ export namespace SessionSummary {
`,
},
],
headers: small.info.headers
})
summary = result.text
}