mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-23 02:34:21 +01:00
zen: support 1M claude context
This commit is contained in:
@@ -67,7 +67,7 @@ export async function handler(
|
|||||||
const headers = input.request.headers
|
const headers = input.request.headers
|
||||||
headers.delete("host")
|
headers.delete("host")
|
||||||
headers.delete("content-length")
|
headers.delete("content-length")
|
||||||
providerInfo.modifyHeaders(headers, providerInfo.apiKey)
|
providerInfo.modifyHeaders(headers, body, providerInfo.apiKey)
|
||||||
Object.entries(providerInfo.headerMappings ?? {}).forEach(([k, v]) => {
|
Object.entries(providerInfo.headerMappings ?? {}).forEach(([k, v]) => {
|
||||||
headers.set(k, headers.get(v)!)
|
headers.set(k, headers.get(v)!)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -17,9 +17,12 @@ type Usage = {
|
|||||||
export const anthropicHelper = {
|
export const anthropicHelper = {
|
||||||
format: "anthropic",
|
format: "anthropic",
|
||||||
modifyUrl: (providerApi: string) => providerApi + "/messages",
|
modifyUrl: (providerApi: string) => providerApi + "/messages",
|
||||||
modifyHeaders: (headers: Headers, apiKey: string) => {
|
modifyHeaders: (headers: Headers, body: Record<string, any>, apiKey: string) => {
|
||||||
headers.set("x-api-key", apiKey)
|
headers.set("x-api-key", apiKey)
|
||||||
headers.set("anthropic-version", headers.get("anthropic-version") ?? "2023-06-01")
|
headers.set("anthropic-version", headers.get("anthropic-version") ?? "2023-06-01")
|
||||||
|
if (body.model.startsWith("claude-sonnet-")) {
|
||||||
|
headers.set("anthropic-beta", "context-1m-2025-08-07")
|
||||||
|
}
|
||||||
},
|
},
|
||||||
modifyBody: (body: Record<string, any>) => {
|
modifyBody: (body: Record<string, any>) => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ type Usage = {
|
|||||||
export const oaCompatHelper = {
|
export const oaCompatHelper = {
|
||||||
format: "oa-compat",
|
format: "oa-compat",
|
||||||
modifyUrl: (providerApi: string) => providerApi + "/chat/completions",
|
modifyUrl: (providerApi: string) => providerApi + "/chat/completions",
|
||||||
modifyHeaders: (headers: Headers, apiKey: string) => {
|
modifyHeaders: (headers: Headers, body: Record<string, any>, apiKey: string) => {
|
||||||
headers.set("authorization", `Bearer ${apiKey}`)
|
headers.set("authorization", `Bearer ${apiKey}`)
|
||||||
},
|
},
|
||||||
modifyBody: (body: Record<string, any>) => {
|
modifyBody: (body: Record<string, any>) => {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ type Usage = {
|
|||||||
export const openaiHelper = {
|
export const openaiHelper = {
|
||||||
format: "openai",
|
format: "openai",
|
||||||
modifyUrl: (providerApi: string) => providerApi + "/responses",
|
modifyUrl: (providerApi: string) => providerApi + "/responses",
|
||||||
modifyHeaders: (headers: Headers, apiKey: string) => {
|
modifyHeaders: (headers: Headers, body: Record<string, any>, apiKey: string) => {
|
||||||
headers.set("authorization", `Bearer ${apiKey}`)
|
headers.set("authorization", `Bearer ${apiKey}`)
|
||||||
},
|
},
|
||||||
modifyBody: (body: Record<string, any>) => {
|
modifyBody: (body: Record<string, any>) => {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import {
|
|||||||
export type ProviderHelper = {
|
export type ProviderHelper = {
|
||||||
format: Format
|
format: Format
|
||||||
modifyUrl: (providerApi: string) => string
|
modifyUrl: (providerApi: string) => string
|
||||||
modifyHeaders: (headers: Headers, apiKey: string) => void
|
modifyHeaders: (headers: Headers, body: Record<string, any>, apiKey: string) => void
|
||||||
modifyBody: (body: Record<string, any>) => Record<string, any>
|
modifyBody: (body: Record<string, any>) => Record<string, any>
|
||||||
createUsageParser: () => {
|
createUsageParser: () => {
|
||||||
parse: (chunk: string) => void
|
parse: (chunk: string) => void
|
||||||
|
|||||||
Reference in New Issue
Block a user