mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-29 17:55:24 +00:00
feat: 模型数据管理
feat: 模型数据导入 feat: redis 向量入库 feat: 向量索引 feat: 文件导入模型 perf: 交互 perf: prompt
This commit is contained in:
@@ -124,3 +124,15 @@ export const readDocContent = (file: File) =>
|
||||
reject('读取 doc 文件失败');
|
||||
};
|
||||
});
|
||||
|
||||
export const vectorToBuffer = (vector: number[]) => {
|
||||
const float32Arr = new Float32Array(vector);
|
||||
const myBuffer = new ArrayBuffer(float32Arr.length * Float32Array.BYTES_PER_ELEMENT);
|
||||
const myView = new DataView(myBuffer);
|
||||
|
||||
for (let i = 0; i < float32Arr.length; i++) {
|
||||
myView.setFloat32(i * Float32Array.BYTES_PER_ELEMENT, float32Arr[i], true);
|
||||
}
|
||||
|
||||
return Buffer.from(myBuffer);
|
||||
};
|
||||
|
Reference in New Issue
Block a user