zen: gpt safety_identifier
This commit is contained in:
@@ -107,11 +107,14 @@ export async function handler(
|
|||||||
const startTimestamp = Date.now()
|
const startTimestamp = Date.now()
|
||||||
const reqUrl = providerInfo.modifyUrl(providerInfo.api, isStream)
|
const reqUrl = providerInfo.modifyUrl(providerInfo.api, isStream)
|
||||||
const reqBody = JSON.stringify(
|
const reqBody = JSON.stringify(
|
||||||
providerInfo.modifyBody({
|
providerInfo.modifyBody(
|
||||||
...createBodyConverter(opts.format, providerInfo.format)(body),
|
{
|
||||||
model: providerInfo.model,
|
...createBodyConverter(opts.format, providerInfo.format)(body),
|
||||||
...(providerInfo.payloadModifier ?? {}),
|
model: providerInfo.model,
|
||||||
}),
|
...(providerInfo.payloadModifier ?? {}),
|
||||||
|
},
|
||||||
|
authInfo?.workspaceID,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
logger.debug("REQUEST URL: " + reqUrl)
|
logger.debug("REQUEST URL: " + reqUrl)
|
||||||
logger.debug("REQUEST: " + reqBody.substring(0, 300) + "...")
|
logger.debug("REQUEST: " + reqBody.substring(0, 300) + "...")
|
||||||
|
|||||||
@@ -18,9 +18,10 @@ export const openaiHelper: ProviderHelper = () => ({
|
|||||||
modifyHeaders: (headers: Headers, body: Record<string, any>, 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>, workspaceID?: string) => ({
|
||||||
return body
|
...body,
|
||||||
},
|
...(workspaceID ? { safety_identifier: workspaceID } : {}),
|
||||||
|
}),
|
||||||
createBinaryStreamDecoder: () => undefined,
|
createBinaryStreamDecoder: () => undefined,
|
||||||
streamSeparator: "\n\n",
|
streamSeparator: "\n\n",
|
||||||
createUsageParser: () => {
|
createUsageParser: () => {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export type ProviderHelper = (input: { reqModel: string; providerModel: string }
|
|||||||
format: ZenData.Format
|
format: ZenData.Format
|
||||||
modifyUrl: (providerApi: string, isStream?: boolean) => string
|
modifyUrl: (providerApi: string, isStream?: boolean) => string
|
||||||
modifyHeaders: (headers: Headers, body: Record<string, any>, 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>, workspaceID?: string) => Record<string, any>
|
||||||
createBinaryStreamDecoder: () => ((chunk: Uint8Array) => Uint8Array | undefined) | undefined
|
createBinaryStreamDecoder: () => ((chunk: Uint8Array) => Uint8Array | undefined) | undefined
|
||||||
streamSeparator: string
|
streamSeparator: string
|
||||||
createUsageParser: () => {
|
createUsageParser: () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user