* model config

* feat: model config ui

* perf: rename variable

* feat: custom request url

* perf: model buffer

* perf: init model

* feat: json model config

* auto login

* fix: ts

* update packages

* package

* fix: dockerfile
This commit is contained in:
Archer
2025-01-22 22:59:28 +08:00
committed by archer
parent c393002f1d
commit 12c6ecb987
93 changed files with 2361 additions and 564 deletions

View File

@@ -1,11 +1,11 @@
import { VectorModelItemType } from '@fastgpt/global/core/ai/model.d';
import { EmbeddingModelItemType } from '@fastgpt/global/core/ai/model.d';
import { getAIApi } from '../config';
import { countPromptTokens } from '../../../common/string/tiktoken/index';
import { EmbeddingTypeEnm } from '@fastgpt/global/core/ai/constants';
import { addLog } from '../../../common/system/log';
type GetVectorProps = {
model: VectorModelItemType;
model: EmbeddingModelItemType;
input: string;
type?: `${EmbeddingTypeEnm}`;
};
@@ -24,13 +24,23 @@ export async function getVectorsByText({ model, input, type }: GetVectorProps) {
// input text to vector
const result = await ai.embeddings
.create({
...model.defaultConfig,
...(type === EmbeddingTypeEnm.db && model.dbConfig),
...(type === EmbeddingTypeEnm.query && model.queryConfig),
model: model.model,
input: [input]
})
.create(
{
...model.defaultConfig,
...(type === EmbeddingTypeEnm.db && model.dbConfig),
...(type === EmbeddingTypeEnm.query && model.queryConfig),
model: model.model,
input: [input]
},
model.requestUrl && model.requestAuth
? {
path: model.requestUrl,
headers: {
Authorization: `Bearer ${model.requestAuth}`
}
}
: {}
)
.then(async (res) => {
if (!res.data) {
addLog.error('Embedding API is not responding', res);