update doc ;perf: model test (#4098)

* perf: extract array

* update doc

* perf: model test

* perf: model test
This commit is contained in:
Archer
2025-03-11 14:56:13 +08:00
committed by archer
parent bcd0b010a6
commit a3df9ea531
21 changed files with 144 additions and 79 deletions

View File

@@ -6,10 +6,12 @@ import { getSTTModel } from '../model';
export const aiTranscriptions = async ({
model,
fileStream
fileStream,
headers
}: {
model: string;
fileStream: fs.ReadStream;
headers?: Record<string, string>;
}) => {
const data = new FormData();
data.append('model', model);
@@ -30,7 +32,8 @@ export const aiTranscriptions = async ({
Authorization: modelData.requestAuth
? `Bearer ${modelData.requestAuth}`
: aiAxiosConfig.authorization,
...data.getHeaders()
...data.getHeaders(),
...headers
},
data: data
});

View File

@@ -76,7 +76,7 @@
{
"model": "qwen-max",
"name": "Qwen-max",
"maxContext": 8000,
"maxContext": 32000,
"maxResponse": 4000,
"quoteMaxToken": 6000,
"maxTemperature": 1,

View File

@@ -8,10 +8,11 @@ type GetVectorProps = {
model: EmbeddingModelItemType;
input: string;
type?: `${EmbeddingTypeEnm}`;
headers?: Record<string, string>;
};
// text to vector
export async function getVectorsByText({ model, input, type }: GetVectorProps) {
export async function getVectorsByText({ model, input, type, headers }: GetVectorProps) {
if (!input) {
return Promise.reject({
code: 500,
@@ -37,9 +38,10 @@ export async function getVectorsByText({ model, input, type }: GetVectorProps) {
path: model.requestUrl,
headers: model.requestAuth
? {
Authorization: `Bearer ${model.requestAuth}`
Authorization: `Bearer ${model.requestAuth}`,
...headers
}
: undefined
: headers
}
: {}
)

View File

@@ -16,11 +16,13 @@ type ReRankCallResult = { id: string; score?: number }[];
export function reRankRecall({
model = getDefaultRerankModel(),
query,
documents
documents,
headers
}: {
model?: ReRankModelItemType;
query: string;
documents: { id: string; text: string }[];
headers?: Record<string, string>;
}): Promise<ReRankCallResult> {
if (!model) {
return Promise.reject('no rerank model');
@@ -41,7 +43,8 @@ export function reRankRecall({
},
{
headers: {
Authorization: model.requestAuth ? `Bearer ${model.requestAuth}` : authorization
Authorization: model.requestAuth ? `Bearer ${model.requestAuth}` : authorization,
...headers
},
timeout: 30000
}