Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 1x 1x 1x | import { SERVER_URL } from "@config/base";
import { requestUrlAndGetPromiseThrowError } from "@utils/FetchUtils";
export interface ChatMessageProps {
msgIndex: number;
content: string;
userId: number;
mimeType: string;
dateCreated: number;
uuid: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
extInfo: Record<string, any>;
}
export interface PullChatMessageProps {
msgs: ChatMessageProps[];
}
export const pullChatMessages = async (conversationId: number, latestMsgIndex: number): Promise<PullChatMessageProps> => {
return await requestUrlAndGetPromiseThrowError(`${SERVER_URL}/chat/pull?conversationId=${conversationId}&latestMsgIndex=${latestMsgIndex}`, {}, {
useCache: false,
});
};
export const askAiAssistant = async (conversationId: number, mimeType: string, content: string, uuid: string | number): Promise<ChatMessageProps> => {
return await requestUrlAndGetPromiseThrowError(`${SERVER_URL}/chat`, {
method: "POST",
body: JSON.stringify({
conversationId,
mimeType,
content,
uuid,
})
});
};
export const listHistoricalChatMessages = async (conversationId: number, stopMsgIndex?: number, limit?: number): Promise<PullChatMessageProps> => {
return await requestUrlAndGetPromiseThrowError(`${SERVER_URL}/chat/list?conversationId=${conversationId}${stopMsgIndex ? `&stopMsgIndex=${stopMsgIndex}` : ''}${stopMsgIndex ? `&limit=${limit}` : ''}`, {});
}; |