Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@baiducloud/qianfan

Package Overview
Dependencies
Maintainers
0
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@baiducloud/qianfan - npm Package Compare versions

Comparing version 0.1.8 to 0.1.9

4

package.json
{
"name": "@baiducloud/qianfan",
"version": "0.1.8",
"version": "0.1.9",
"publishConfig": {

@@ -68,2 +68,2 @@ "access": "public",

}
}
}

@@ -186,2 +186,5 @@ // Copyright (c) 2024 Baidu, Inc. All Rights Reserved.

if (this.qianfanAk && this.qianfanSk) {
if (!AKPath) {
throw new Error(`${model} is not supported`);
}
if (this.expires_in < Date.now() / 1000) {

@@ -188,0 +191,0 @@ await this.getAccessToken();

@@ -15,3 +15,2 @@ // Copyright (c) 2024 Baidu, Inc. All Rights Reserved.

import {ModelType} from '../enum';

@@ -24,25 +23,53 @@

const chatModelEndpoints = new Map<string, string>([
['ernie-4.0-8k-latest', 'ernie-4.0-8k-latest'],
['ernie-4.0-8k-0613', 'ernie-4.0-8k-0613'],
['ernie-3.5-8k-0613', 'ernie-3.5-8k-0613'],
// ERNIE 4.0
['ernie-4.0-8k', 'completions_pro'],
['ernie-4.0-8k-preemptible', 'completions_pro_preemptible'],
['ernie-4.0-8k-preview', 'ernie-4.0-8k-preview'],
['ernie-4.0-8k-latest', 'ernie-4.0-8k-latest'],
['ernie-4.0-8k-0329', 'ernie-4.0-8k-0329'],
['ernie-4.0-8k-0104', 'ernie-4.0-8k-0104'],
['ernie-4.0-8k-0613', 'ernie-4.0-8k-0613'],
// ERNIE 4.0 Turbo
['ernie-4.0-turbo-8k', 'ernie-4.0-turbo-8k'],
['ernie-4.0-turbo-8k-preview', 'ernie-4.0-turbo-8k-preview'],
// ERNIE 3.5
['ernie-3.5-8k', 'completions'],
['ernie-3.5-8k-0205', 'ernie-3.5-8k-0205'],
['ernie-3.5-8k-1222', 'ernie-3.5-8k-1222'],
['ernie-3.5-4k-0205', 'ernie-3.5-4k-0205'],
['ernie-3.5-8k-preemptible', 'completions_preemptible'],
['ernie-3.5-8k-preview', 'ernie-3.5-8k-preview'],
['ernie-3.5-8k-0329', 'ernie-3.5-8k-0329'],
['ernie-3.5-128k', 'ernie-3.5-128k'],
['ernie-3.5-8k-0613', 'ernie-3.5-8k-0613'],
['ernie-3.5-8k-0701', 'ernie-3.5-8k-0701'],
// ERNIE Speed Pro
['ernie-speed-pro-8k', 'ernie-speed-pro-8k'],
['ernie-speed-pro-128k', 'ernie-speed-pro-128k'],
// ERNIE Speed
['ernie-speed-8k', 'ernie_speed'],
['ernie-speed-128k', 'ernie-speed-128k'],
['ernie-character-8k-0321', 'ernie-char-8k'],
// ERNIE Lite Pro
['ernie-lite-pro-8k', 'ernie-lite-pro-8k'],
// ERNIE Lite
['ernie-lite-8k-0922', 'eb-instant'],
['ernie-lite-8k', 'ernie-lite-8k'],
['ernie-lite-8k-0725', 'ernie-lite-8k-0725'],
['ernie-lite-4k-0704', 'ernie-lite-4k-0704'],
['ernie-lite-4k-0516', 'ernie-lite-4k-0516'],
['ernie-lite-128k-0419', 'ernie-lite-128k-0419'],
['ernie-lite-8k-0308', 'ernie-lite-8k'],
['ernie-tiny-8k', 'ernie-tiny-8k'],
['ernie-novel-8k', 'ernie-novel-8k'],
['ernie-character-8k', 'ernie-char-8k'],
['ernie-functions-8k', 'ernie-func-8k'],
['ernie-tiny-8k', 'ernie-tiny-8k'],
['ernie speed-appbuilder', 'ai_apaas'],
['qianfan-dynamic-8k', 'qianfan-dynamic-8k'],
// ERNIE AppBuilder
['ernie-speed-appbuilder', 'ai_apaas'],
['ernie-4.0-8k-preemptible', 'completions_pro_preemptible'],
['ernie-4.0-8k-0104', 'ernie-4.0-8k-0104'],
['ernie-3.5-8k-0205', 'ernie-3.5-8k-0205'],
['ernie-3.5-8k-1222', 'ernie-3.5-8k-1222'],
['ernie-3.5-4k-0205', 'ernie-3.5-4k-0205'],
['ernie-3.5-8k-preemptible', 'completions_preemptible'],
['ernie-character-8k-0321', 'ernie-char-8k'],
['gemma-7b-it', 'gemma_7b_it'],

@@ -74,8 +101,5 @@ ['yi-34b-chat', 'yi_34b_chat'],

['qianfan-chinese-llama-2-13b', 'qianfan_chinese_llama_2_13b'],
['ernie-4.0-turbo-8k', 'ernie-4.0-turbo-8k'],
['ernie-lite-appbuilder-8k-0614', 'ai_apaas_lite'],
['ernie-character-fiction-8k', 'ernie-char-fiction-8k'],
['ernie-3.5-128k', 'ernie-3.5-128k'],
['ernie-lite-8k', 'ernie-lite-8k'],
['ernie-lite-v', 'ernie-lite-v'],
['ernie-character-fiction-8k', 'ernie-char-fiction-8k']
]);

@@ -85,3 +109,3 @@ // 定义 "COMPLETIONS" 类型的模型及其 endpoints

['sqlcoder-7b', 'sqlcoder_7b'],
['codellama-7b-instruct', 'codellama_7b_instruct'],
['codellama-7b-instruct', 'codellama_7b_instruct']
]);

@@ -94,24 +118,16 @@

['bge-large-en', 'bge_large_en'],
['tao-8k', 'tao_8k'],
['tao-8k', 'tao_8k']
]);
// 定义 "TEXT_2_IMAGE" 类型的模型及其 endpoints
const text2imageEndpoints = new Map<string, string>([
['stable-diffusion-xl', 'sd_xl'],
]);
const text2imageEndpoints = new Map<string, string>([['stable-diffusion-xl', 'sd_xl']]);
// 定义 "IMAGE_2_TEXT" 类型的模型及其 endpoints
const image2textEndpoints = new Map<string, string>([
['fuyu-8b', 'fuyu_8b'],
]);
const image2textEndpoints = new Map<string, string>([['fuyu-8b', 'fuyu_8b']]);
// 一言插件模型
const pluginEndpoints = new Map<string, string>([
['ebpluginv2', 'erniebot/plugin'],
]);
const pluginEndpoints = new Map<string, string>([['ebpluginv2', 'erniebot/plugin']]);
// 重新排序向量模型
const rerankerEndpoints = new Map<string, string>([
['bce-reranker-base_v1', 'bce_reranker_base'],
]);
const rerankerEndpoints = new Map<string, string>([['bce-reranker-base_v1', 'bce_reranker_base']]);

@@ -135,2 +151,2 @@ // 将模型 endpoints 映射添加到主映射中

return undefined;
}
}

@@ -29,3 +29,4 @@ // Copyright (c) 2024 Baidu, Inc. All Rights Reserved.

return 'browser';
} else if (typeof process !== 'undefined' && process?.release?.name === 'node') {
}
else if (typeof process !== 'undefined' && process?.release?.name === 'node') {
return 'node';

@@ -52,5 +53,5 @@ }

ak,
sk
sk,
},
endpoint: baseUrl
endpoint: baseUrl,
};

@@ -67,4 +68,4 @@ }

export function getRequestBody(body: ReqBody, model, version: string): string {
const request_source =
getCurrentEnvironment() === 'browser' ? `qianfan_fe_sdk_v${version}` : `qianfan_js_sdk_v${version}`;
const request_source
= getCurrentEnvironment() === 'browser' ? `qianfan_fe_sdk_v${version}` : `qianfan_js_sdk_v${version}`;

@@ -76,4 +77,4 @@ const modifiedBody = {

...body.extra_parameters,
request_source
}
request_source,
},
};

@@ -109,3 +110,3 @@ return JSON.stringify(modifiedBody);

endpoint = '',
type
type,
}: {

@@ -123,7 +124,7 @@ model?: string;

return `${basePath}${suffix}${endpoint}`;
} else if (model && modelInfoMap && modelInfoMap[model]) {
}
else if (model && modelInfoMap && modelInfoMap[model]) {
const modelEndpoint = getModelEndpoint(model, modelInfoMap);
return Authentication === 'IAM' ? `${BASE_PATH}${modelEndpoint}` : `${api_base}${modelEndpoint}`;
}
throw new Error('Model is not supported');
};

@@ -185,3 +186,3 @@

endpoint = '',
type
type,
}: {

@@ -205,3 +206,3 @@ model?: string;

endpoint,
type
type,
});

@@ -211,3 +212,3 @@ const requestBody = getRequestBody(body, model, packageJson.version);

AKPath,
requestBody
requestBody,
};

@@ -268,3 +269,3 @@ }

modelInfoMapUppercase: modelMap,
modelUppercase: ''
modelUppercase: '',
};

@@ -278,3 +279,3 @@ }

modelUppercase,
modelLowercase
modelLowercase,
};

@@ -353,4 +354,4 @@ }

headers: {
...DEFAULT_HEADERS
}
...DEFAULT_HEADERS,
},
};

@@ -365,5 +366,6 @@ const fetchOptions = await client.getSignature(

return resp;
} catch (error) {
}
catch (error) {
throw error;
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc