36 lines
799 B
TypeScript
36 lines
799 B
TypeScript
import routes from "@/routes";
|
|
import { getAuthHeaders } from "../utils";
|
|
import { AuthPayload } from "../types";
|
|
|
|
export type Payload = {
|
|
chatId: string
|
|
} & AuthPayload
|
|
|
|
interface IResponseGetSuccess {
|
|
messages: IMessage[]
|
|
}
|
|
|
|
export interface IMessage {
|
|
id: string,
|
|
role: string,
|
|
text: string,
|
|
userId: string,
|
|
assistantId: string,
|
|
threadId: string,
|
|
chatId: string,
|
|
createdDate: string,
|
|
isRead: boolean
|
|
}
|
|
|
|
// interface IResponseGetError {
|
|
// status: string;
|
|
// message: string;
|
|
// }
|
|
|
|
export type ResponseGet = IResponseGetSuccess
|
|
|
|
export const getRequest = ({ chatId, token }: Payload): Request => {
|
|
const url = new URL(routes.server.getChatMessages(chatId));
|
|
return new Request(url, { method: "GET", headers: getAuthHeaders(token) });
|
|
};
|