feat: convert Chat.jsx to RQ

This commit is contained in:
Daniel D Orlando 2023-04-03 16:46:35 -07:00
parent 573112de7b
commit 1cb8ef9803
6 changed files with 53 additions and 111 deletions

View file

@ -2,10 +2,6 @@ import * as t from './types';
import request from './request';
import * as endpoints from './endpoints';
export function postAICompletion(payload: t.TAICompletionRequest) {
return request.post(endpoints.getAICompletion(), payload);
}
export function getConversations(pageNumber: string): Promise<t.TGetConversationsResponse> {
return request.get(endpoints.getConversations(pageNumber));
}

View file

@ -1,6 +1,3 @@
export const openAiModels = () => {
return `/api/open-ai-models`;
};
export const getModels = () => {
return `/api/models`;

View file

@ -57,6 +57,23 @@ export const useGetConversationByIdQuery = (
);
}
//This isn't ideal because its just a query and we're using mutation, but it was the only way
//to make it work with how the Chat component is structured
export const useGetConversationByIdMutation = (
id: string,
callback: (data: t.TConversation) => void
): UseMutationResult<t.TConversation> => {
const queryClient = useQueryClient();
return useMutation(() => dataService.getConversationById(id),
{
onSuccess: (res: t.TConversation) => {
callback(res);
queryClient.invalidateQueries([QueryKeys.conversation, id]);
},
}
);
};
export const useUpdateConversationMutation = (
id: string
): UseMutationResult<

View file

@ -1,9 +1,9 @@
export type TMessage = {
messageId: string,
conversationId: string,
conversationSignature: string | null,
// conversationSignature: string | null,
clientId: string,
invocationId: string,
// invocationId: string,
parentMessageId: string,
sender: string,
text: string,
@ -11,12 +11,12 @@ export type TMessage = {
error: boolean,
createdAt: string,
updatedAt: string,
searchResult: string[],
submitting: boolean,
children?: any[] | undefined,
bgColor?: string,
model?: string,
cancelled?: boolean
// searchResult: string[],
// submitting: boolean,
// children?: any[] | undefined,
// bgColor?: string,
// model?: string,
// cancelled?: boolean
};
export type TMessageTreeNode = {}