fix watsonx zen-api-key
This commit is contained in:
parent
837ee01816
commit
a2df09eda2
2 changed files with 11 additions and 9 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@continuedev/openai-adapters",
|
||||
"version": "1.0.28",
|
||||
"version": "1.0.29",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
|
|
|||
|
|
@ -35,14 +35,6 @@ export class WatsonXApi implements BaseLlmApi {
|
|||
this.deploymentId = config.env.deploymentId;
|
||||
}
|
||||
|
||||
private async getHeaders(): Promise<Record<string, string>> {
|
||||
const bearer = await this.getBearerToken();
|
||||
return {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${bearer.token}`,
|
||||
};
|
||||
}
|
||||
|
||||
async getBearerToken(): Promise<{ token: string; expiration: number }> {
|
||||
if (this.apiBase?.includes("cloud.ibm.com")) {
|
||||
// watsonx SaaS
|
||||
|
|
@ -153,6 +145,16 @@ export class WatsonXApi implements BaseLlmApi {
|
|||
return payload;
|
||||
}
|
||||
|
||||
private async getHeaders(): Promise<Record<string, string>> {
|
||||
const bearer = await this.getBearerToken();
|
||||
const isZenApiKey = bearer.expiration === -1;
|
||||
|
||||
return {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `${isZenApiKey ? "ZenApiKey" : "Bearer"} ${bearer.token}`,
|
||||
};
|
||||
}
|
||||
|
||||
async chatCompletionNonStream(
|
||||
body: ChatCompletionCreateParamsNonStreaming,
|
||||
signal: AbortSignal,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue