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.3 to 0.1.4

2

package.json
{
"name": "@baiducloud/qianfan",
"version": "0.1.3",
"version": "0.1.4",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public",

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

*/
public async chat(body: ChatBody, model = 'ERNIE-Bot-turbo'): Promise<Resp | AsyncIterable<Resp>> {
public async chat(body: ChatBody, model = 'ERNIE-Lite-8K'): Promise<Resp | AsyncIterable<Resp>> {
const stream = body.stream ?? false;

@@ -32,0 +32,0 @@ const {modelInfoMapUppercase, modelUppercase, modelLowercase} = getUpperCaseModelAndModelMap(

@@ -168,6 +168,10 @@ // Copyright (c) 2024 Baidu, Inc. All Rights Reserved.

let buffer = new Uint8Array(); // 初始化缓存的 Buffer
let previousChunkLastByte: number | null = null;
const iter = readableStreamAsyncIterable<Bytes>(response.body);
for await (const chunk of iter) {
if (endsWith1010(chunk as Uint8Array)) {
if (chunk[0] === 10) {
continue;
}
if (previousChunkLastByte === 10) {
buffer = concatUint8Arrays(buffer, chunk as Uint8Array);

@@ -187,2 +191,4 @@

}
// 保存当前 chunk 的最后一个字节
previousChunkLastByte = chunk[chunk.length - 1] as number; ;
}

@@ -370,11 +376,2 @@

// 判断 Uint8Array 是否以 10,10 结尾
function endsWith1010(uintArray: Uint8Array): boolean {
const len = uintArray.length;
if (len < 2) {
return false;
}
return uintArray[len - 2] === 10 && uintArray[len - 1] === 10;
}
// 合并两个 Uint8Array

@@ -381,0 +378,0 @@ function concatUint8Arrays(a: Uint8Array, b: Uint8Array): Uint8Array {

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