Skip to content

Commit efac531

Browse files
authored
fix: rerank model cannot use ai proxy (#3945)
* fix: collection list count * fix: collection list count * fix: rerank model cannot use ai proxy * mongo init
1 parent 4bc7f21 commit efac531

File tree

8 files changed

+43
-7
lines changed

8 files changed

+43
-7
lines changed

packages/service/common/mongo/init.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,30 @@ export async function connectMongo(): Promise<Mongoose> {
1616

1717
console.log('mongo start connect');
1818
try {
19+
// Remove existing listeners to prevent duplicates
20+
connectionMongo.connection.removeAllListeners('error');
21+
connectionMongo.connection.removeAllListeners('disconnected');
1922
connectionMongo.set('strictQuery', false);
2023

2124
connectionMongo.connection.on('error', async (error) => {
2225
console.log('mongo error', error);
23-
await connectionMongo.disconnect();
24-
await delay(1000);
25-
connectMongo();
26+
try {
27+
if (connectionMongo.connection.readyState !== 0) {
28+
await connectionMongo.disconnect();
29+
await delay(1000);
30+
await connectMongo();
31+
}
32+
} catch (error) {}
2633
});
27-
connectionMongo.connection.on('disconnected', () => {
34+
connectionMongo.connection.on('disconnected', async () => {
2835
console.log('mongo disconnected');
36+
try {
37+
if (connectionMongo.connection.readyState !== 0) {
38+
await connectionMongo.disconnect();
39+
await delay(1000);
40+
await connectMongo();
41+
}
42+
} catch (error) {}
2943
});
3044

3145
await connectionMongo.connect(process.env.MONGODB_URI as string, {

packages/service/core/ai/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const getAxiosConfig = (props?: { userKey?: OpenaiAccountType }) => {
3535
const { userKey } = props || {};
3636

3737
const baseUrl = userKey?.baseUrl || global?.systemEnv?.oneapiUrl || openaiBaseUrl;
38-
const apiKey = userKey?.key || global?.systemEnv?.chatApiKey || process.env.CHAT_API_KEY || '';
38+
const apiKey = userKey?.key || global?.systemEnv?.chatApiKey || openaiBaseKey;
3939

4040
return {
4141
baseUrl,
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
22
"provider": "AliCloud",
3-
"list": []
4-
}
3+
"list": [
4+
{
5+
"model": "SenseVoiceSmall",
6+
"name": "SenseVoiceSmall",
7+
"type": "stt"
8+
}
9+
]
10+
}

packages/web/i18n/en/account_model.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"key_type": "API key format:",
2525
"log": "Call log",
2626
"log_detail": "Log details",
27+
"log_request_id_search": "Search by requestId",
2728
"log_status": "Status",
2829
"mapping": "Model Mapping",
2930
"mapping_tip": "A valid Json is required. \nThe model can be mapped when sending a request to the actual address. \nFor example:\n{\n \n \"gpt-4o\": \"gpt-4o-test\"\n\n}\n\nWhen FastGPT requests the gpt-4o model, the gpt-4o-test model is sent to the actual address, instead of gpt-4o.",

packages/web/i18n/zh-CN/account_model.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"key_type": "API key 格式: ",
2525
"log": "调用日志",
2626
"log_detail": "日志详情",
27+
"log_request_id_search": "根据 requestId 搜索",
2728
"log_status": "状态",
2829
"mapping": "模型映射",
2930
"mapping_tip": "需填写一个有效 Json。可在向实际地址发送请求时,对模型进行映射。例如:\n{\n \"gpt-4o\": \"gpt-4o-test\"\n}\n当 FastGPT 请求 gpt-4o 模型时,会向实际地址发送 gpt-4o-test 的模型,而不是 gpt-4o。",

packages/web/i18n/zh-Hant/account_model.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"key_type": "API key 格式:",
2323
"log": "調用日誌",
2424
"log_detail": "日誌詳情",
25+
"log_request_id_search": "根據 requestId 搜索",
2526
"log_status": "狀態",
2627
"mapping": "模型映射",
2728
"mapping_tip": "需填寫一個有效 Json。\n可在向實際地址發送請求時,對模型進行映射。\n例如:\n{\n \n \"gpt-4o\": \"gpt-4o-test\"\n\n}\n\n當 FastGPT 請求 gpt-4o 模型時,會向實際地址發送 gpt-4o-test 的模型,而不是 gpt-4o。",

projects/app/src/pageComponents/account/model/Log/index.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import MyIcon from '@fastgpt/web/components/common/Icon';
3232
import { formatTime2YMDHMS } from '@fastgpt/global/common/string/time';
3333
import MyModal from '@fastgpt/web/components/common/MyModal';
3434
import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip';
35+
import SearchInput from '@fastgpt/web/components/common/Input/SearchInput';
3536

3637
type LogDetailType = {
3738
id: number;
@@ -55,11 +56,13 @@ const ChannelLog = ({ Tab }: { Tab: React.ReactNode }) => {
5556

5657
const isRoot = userInfo?.username === 'root';
5758
const [filterProps, setFilterProps] = useState<{
59+
request_id?: string;
5860
channelId?: string;
5961
model?: string;
6062
code_type: 'all' | 'success' | 'error';
6163
dateRange: DateRangeType;
6264
}>({
65+
request_id: '',
6366
code_type: 'all',
6467
dateRange: {
6568
from: (() => {
@@ -125,6 +128,7 @@ const ChannelLog = ({ Tab }: { Tab: React.ReactNode }) => {
125128
pageSize: 20,
126129
refreshDeps: [filterProps],
127130
params: {
131+
request_id: filterProps.request_id,
128132
channel: filterProps.channelId,
129133
model_name: filterProps.model,
130134
code_type: filterProps.code_type,
@@ -172,6 +176,13 @@ const ChannelLog = ({ Tab }: { Tab: React.ReactNode }) => {
172176
<Flex alignItems={'center'}>
173177
{Tab}
174178
<Box flex={1} />
179+
<Box flex={'0 0 200px'}>
180+
<SearchInput
181+
placeholder={t('account_model:log_request_id_search')}
182+
defaultValue={filterProps.request_id}
183+
onBlur={(e) => setFilterProps({ ...filterProps, request_id: e.target.value })}
184+
/>
185+
</Box>
175186
</Flex>
176187
)}
177188
<HStack spacing={4}>

projects/app/src/web/core/ai/channel.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ export const putChannel = (data: ChannelInfoType) =>
152152
export const deleteChannel = (id: number) => DELETE(`/channel/${id}`);
153153

154154
export const getChannelLog = (params: {
155+
request_id?: string;
155156
channel?: string;
156157
model_name?: string;
157158
code_type?: 'all' | 'success' | 'error';
@@ -164,6 +165,7 @@ export const getChannelLog = (params: {
164165
logs: ChannelLogListItemType[];
165166
total: number;
166167
}>(`/logs/search`, {
168+
request_id: params.request_id,
167169
channel: params.channel,
168170
model_name: params.model_name,
169171
code_type: params.code_type,

0 commit comments

Comments
 (0)