chore: track model variant in honeycomb (#26188)
This commit is contained in:
@@ -7,6 +7,7 @@ export function POST(input: APIEvent) {
|
|||||||
modelList: "lite",
|
modelList: "lite",
|
||||||
parseApiKey: (headers: Headers) => headers.get("authorization")?.split(" ")[1],
|
parseApiKey: (headers: Headers) => headers.get("authorization")?.split(" ")[1],
|
||||||
parseModel: (url: string, body: any) => body.model,
|
parseModel: (url: string, body: any) => body.model,
|
||||||
|
parseVariant: (url: string, body: any) => body.reasoningEffort ?? body.reasoning_effort,
|
||||||
parseIsStream: (url: string, body: any) => !!body.stream,
|
parseIsStream: (url: string, body: any) => !!body.stream,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export function POST(input: APIEvent) {
|
|||||||
modelList: "lite",
|
modelList: "lite",
|
||||||
parseApiKey: (headers: Headers) => headers.get("x-api-key") ?? undefined,
|
parseApiKey: (headers: Headers) => headers.get("x-api-key") ?? undefined,
|
||||||
parseModel: (url: string, body: any) => body.model,
|
parseModel: (url: string, body: any) => body.model,
|
||||||
|
parseVariant: (url: string, body: any) => body.effort,
|
||||||
parseIsStream: (url: string, body: any) => !!body.stream,
|
parseIsStream: (url: string, body: any) => !!body.stream,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ export async function handler(
|
|||||||
modelList: "lite" | "full"
|
modelList: "lite" | "full"
|
||||||
parseApiKey: (headers: Headers) => string | undefined
|
parseApiKey: (headers: Headers) => string | undefined
|
||||||
parseModel: (url: string, body: any) => string
|
parseModel: (url: string, body: any) => string
|
||||||
|
parseVariant: (url: string, body: any) => string | undefined
|
||||||
parseIsStream: (url: string, body: any) => boolean
|
parseIsStream: (url: string, body: any) => boolean
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
@@ -93,6 +94,7 @@ export async function handler(
|
|||||||
const url = input.request.url
|
const url = input.request.url
|
||||||
const body = await input.request.json()
|
const body = await input.request.json()
|
||||||
const model = opts.parseModel(url, body)
|
const model = opts.parseModel(url, body)
|
||||||
|
const variant = opts.parseVariant(url, body)
|
||||||
const isStream = opts.parseIsStream(url, body)
|
const isStream = opts.parseIsStream(url, body)
|
||||||
const rawIp = input.request.headers.get("x-real-ip") ?? ""
|
const rawIp = input.request.headers.get("x-real-ip") ?? ""
|
||||||
const ip = rawIp.includes(":") ? rawIp.split(":").slice(0, 4).join(":") : rawIp
|
const ip = rawIp.includes(":") ? rawIp.split(":").slice(0, 4).join(":") : rawIp
|
||||||
@@ -109,6 +111,7 @@ export async function handler(
|
|||||||
request: requestId,
|
request: requestId,
|
||||||
client: ocClient,
|
client: ocClient,
|
||||||
user_agent: userAgent,
|
user_agent: userAgent,
|
||||||
|
"model.variant": variant,
|
||||||
})
|
})
|
||||||
const zenData = ZenData.list(opts.modelList)
|
const zenData = ZenData.list(opts.modelList)
|
||||||
const modelInfo = validateModel(zenData, model)
|
const modelInfo = validateModel(zenData, model)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export function POST(input: APIEvent) {
|
|||||||
modelList: "full",
|
modelList: "full",
|
||||||
parseApiKey: (headers: Headers) => headers.get("authorization")?.split(" ")[1],
|
parseApiKey: (headers: Headers) => headers.get("authorization")?.split(" ")[1],
|
||||||
parseModel: (url: string, body: any) => body.model,
|
parseModel: (url: string, body: any) => body.model,
|
||||||
|
parseVariant: (url: string, body: any) => body.reasoningEffort ?? body.reasoning_effort,
|
||||||
parseIsStream: (url: string, body: any) => !!body.stream,
|
parseIsStream: (url: string, body: any) => !!body.stream,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export function POST(input: APIEvent) {
|
|||||||
modelList: "full",
|
modelList: "full",
|
||||||
parseApiKey: (headers: Headers) => headers.get("x-api-key") ?? undefined,
|
parseApiKey: (headers: Headers) => headers.get("x-api-key") ?? undefined,
|
||||||
parseModel: (url: string, body: any) => body.model,
|
parseModel: (url: string, body: any) => body.model,
|
||||||
|
parseVariant: (url: string, body: any) => body.effort,
|
||||||
parseIsStream: (url: string, body: any) => !!body.stream,
|
parseIsStream: (url: string, body: any) => !!body.stream,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export function POST(input: APIEvent) {
|
|||||||
modelList: "full",
|
modelList: "full",
|
||||||
parseApiKey: (headers: Headers) => headers.get("x-goog-api-key") ?? undefined,
|
parseApiKey: (headers: Headers) => headers.get("x-goog-api-key") ?? undefined,
|
||||||
parseModel: (url: string, _body: any) => url.split("/").pop()?.split(":")?.[0] ?? "",
|
parseModel: (url: string, _body: any) => url.split("/").pop()?.split(":")?.[0] ?? "",
|
||||||
|
parseVariant: (url: string, body: any) => body.thinkingLevel,
|
||||||
parseIsStream: (url: string, _body: any) =>
|
parseIsStream: (url: string, _body: any) =>
|
||||||
// ie. url: https://opencode.ai/zen/v1/models/gemini-3-pro:streamGenerateContent?alt=sse'
|
// ie. url: https://opencode.ai/zen/v1/models/gemini-3-pro:streamGenerateContent?alt=sse'
|
||||||
url.split("/").pop()?.split(":")?.[1]?.startsWith("streamGenerateContent") ?? false,
|
url.split("/").pop()?.split(":")?.[1]?.startsWith("streamGenerateContent") ?? false,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export function POST(input: APIEvent) {
|
|||||||
modelList: "full",
|
modelList: "full",
|
||||||
parseApiKey: (headers: Headers) => headers.get("authorization")?.split(" ")[1],
|
parseApiKey: (headers: Headers) => headers.get("authorization")?.split(" ")[1],
|
||||||
parseModel: (url: string, body: any) => body.model,
|
parseModel: (url: string, body: any) => body.model,
|
||||||
|
parseVariant: (url: string, body: any) => body.reasoning?.effort,
|
||||||
parseIsStream: (url: string, body: any) => !!body.stream,
|
parseIsStream: (url: string, body: any) => !!body.stream,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export default {
|
|||||||
url.pathname !== "/zen/go/v1/responses" &&
|
url.pathname !== "/zen/go/v1/responses" &&
|
||||||
!url.pathname.startsWith("/zen/go/v1/models/")
|
!url.pathname.startsWith("/zen/go/v1/models/")
|
||||||
)
|
)
|
||||||
return
|
continue
|
||||||
|
|
||||||
let data = {
|
let data = {
|
||||||
"cf.continent": event.event.request.cf?.continent,
|
"cf.continent": event.event.request.cf?.continent,
|
||||||
|
|||||||
Reference in New Issue
Block a user