mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-29 09:44:47 +00:00
v4.2 (#217)
* fix: chat module link * fix: url fetch check * fix: import file ui * feat: app logs * perf: iframe icon * imgs cdn * perf: click range and pg
This commit is contained in:
@@ -64,6 +64,7 @@ try {
|
||||
ChatItemSchema.index({ time: -1 });
|
||||
ChatItemSchema.index({ userId: 1 });
|
||||
ChatItemSchema.index({ appId: 1 });
|
||||
ChatItemSchema.index({ chatId: 1 });
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
@@ -10,6 +10,6 @@ export const dispatchHistory = (props: Record<string, any>) => {
|
||||
const { maxContext = 5, history = [] } = props as HistoryProps;
|
||||
|
||||
return {
|
||||
history: history.slice(-maxContext)
|
||||
history: maxContext > 0 ? history.slice(-maxContext) : []
|
||||
};
|
||||
};
|
||||
|
@@ -1,4 +1,6 @@
|
||||
import { ChatModuleEnum, TaskResponseKeyEnum } from '@/constants/chat';
|
||||
import { HttpPropsEnum } from '@/constants/flow/flowField';
|
||||
import { ChatHistoryItemResType } from '@/types/chat';
|
||||
import type { NextApiResponse } from 'next';
|
||||
|
||||
export type HttpRequestProps = {
|
||||
@@ -11,6 +13,7 @@ export type HttpRequestProps = {
|
||||
export type HttpResponse = {
|
||||
[HttpPropsEnum.finish]: boolean;
|
||||
[HttpPropsEnum.failed]?: boolean;
|
||||
[TaskResponseKeyEnum.responseData]: ChatHistoryItemResType;
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
@@ -22,12 +25,22 @@ export const dispatchHttpRequest = async (props: Record<string, any>): Promise<H
|
||||
|
||||
return {
|
||||
[HttpPropsEnum.finish]: true,
|
||||
[TaskResponseKeyEnum.responseData]: {
|
||||
moduleName: ChatModuleEnum.Http,
|
||||
price: 0,
|
||||
httpResult: response
|
||||
},
|
||||
...response
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
[HttpPropsEnum.finish]: true,
|
||||
[HttpPropsEnum.failed]: true
|
||||
[HttpPropsEnum.failed]: true,
|
||||
[TaskResponseKeyEnum.responseData]: {
|
||||
moduleName: ChatModuleEnum.Http,
|
||||
price: 0,
|
||||
httpResult: {}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
@@ -2,7 +2,7 @@ import { Pool } from 'pg';
|
||||
import type { QueryResultRow } from 'pg';
|
||||
import { PgTrainingTableName } from '@/constants/plugin';
|
||||
|
||||
export const connectPg = async () => {
|
||||
export const connectPg = async (): Promise<Pool> => {
|
||||
if (global.pgClient) {
|
||||
return global.pgClient;
|
||||
}
|
||||
@@ -17,6 +17,7 @@ export const connectPg = async () => {
|
||||
global.pgClient.on('error', (err) => {
|
||||
console.log(err);
|
||||
global.pgClient = null;
|
||||
connectPg();
|
||||
});
|
||||
|
||||
try {
|
||||
@@ -25,7 +26,7 @@ export const connectPg = async () => {
|
||||
return global.pgClient;
|
||||
} catch (error) {
|
||||
global.pgClient = null;
|
||||
return Promise.reject(error);
|
||||
return connectPg();
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user