* 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:
Archer
2023-08-24 21:08:49 +08:00
committed by GitHub
parent 2b50dac0e7
commit 9415e22de9
30 changed files with 506 additions and 63 deletions

View File

@@ -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);
}

View File

@@ -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) : []
};
};

View File

@@ -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: {}
}
};
}
};

View File

@@ -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();
}
};