This commit is contained in:
Archer
2023-12-27 11:07:39 +08:00
committed by GitHub
parent 86286efb54
commit 759a2330e6
182 changed files with 3099 additions and 81685 deletions

View File

@@ -60,7 +60,10 @@ export async function getVectorsByText({
}
function unityDimensional(vector: number[]) {
if (vector.length > 1536) return Promise.reject('向量维度不能超过 1536');
if (vector.length > 1536) {
console.log(`当前向量维度为: ${vector.length}, 向量维度不能超过 1536, 已自动截取前 1536 维度`);
return vector.slice(0, 1536);
}
let resultVector = vector;
const vectorLen = vector.length;

View File

@@ -43,6 +43,9 @@ export async function generateVector(): Promise<any> {
lockTime: new Date()
}
)
.sort({
weight: -1
})
.select({
_id: 1,
userId: 1,
@@ -137,6 +140,7 @@ export async function generateVector(): Promise<any> {
indexes: dataItem.indexes,
model: data.model
});
// push bill
pushGenerateVectorBill({
teamId: data.teamId,

View File

@@ -138,6 +138,9 @@ export const dispatchChatCompletion = async (props: ChatProps): Promise<ChatResp
temperature,
max_tokens,
stream,
presence_penalty: 0,
frequency_penalty: 0,
top_p: 1,
// seed: temperature < 0.3 ? 1 : undefined,
messages: concatMessages
},

View File

@@ -258,9 +258,9 @@ export function pushReRankBill({
if (!model) return { total: 0 };
const textLength = inputs.reduce((sum, item) => sum + item.text.length, 0);
const ratio = Math.ceil(textLength / 1000);
const ratio = textLength / 1000;
const total = model.price * PRICE_SCALE * ratio;
const total = Math.ceil(model.price * PRICE_SCALE * ratio);
const name = 'wallet.bill.ReRank';
createBill({
@@ -274,7 +274,7 @@ export function pushReRankBill({
moduleName: name,
amount: total,
model: model.name,
tokenLen: 1
tokenLen: textLength
}
]
});