update conversation ui
This commit is contained in:
1 parent
297dd3ef2f
commit
b98f8de879
8 files changed
+108
-29
No files matched your search
@@ -44,6 +44,9 @@ export interface IChatMessage {
|
||||
export interface IChatConversation {
|
||||
id: string;
|
||||
messages: IChatMessage[];
|
||||
title?: string;
|
||||
deleting?: boolean;
|
||||
editing?: boolean;
|
||||
}
|
||||
|
||||
export interface IChatAskOptions {
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
import { ENDPOINT_API } from '../common/contants';
|
||||
|
||||
class ChatOperator {
|
||||
async ask(data: IChatAskRequest, options: IChatAskOptions): Promise<AxiosResponse<IChatAskResponse>> {
|
||||
async askQuestion(data: IChatAskRequest, options: IChatAskOptions): Promise<AxiosResponse<IChatAskResponse>> {
|
||||
return await axios.post(options.path, data, {
|
||||
headers: {
|
||||
authorization: `Bearer ${options.token}`,
|
||||
@@ -32,7 +32,7 @@ class ChatOperator {
|
||||
});
|
||||
}
|
||||
|
||||
async conversation(id: string | undefined): Promise<AxiosResponse<IChatConversation>> {
|
||||
async getConversation(id: string | undefined): Promise<AxiosResponse<IChatConversation>> {
|
||||
return await axios.post(
|
||||
`/chatgpt/conversations`,
|
||||
{
|
||||
@@ -48,7 +48,7 @@ class ChatOperator {
|
||||
);
|
||||
}
|
||||
|
||||
async conversations(ids: string[]): Promise<AxiosResponse<IChatConversation[]>> {
|
||||
async getConversations(ids: string[]): Promise<AxiosResponse<IChatConversation[]>> {
|
||||
return await axios.post(
|
||||
`/chatgpt/conversations`,
|
||||
{
|
||||
@@ -63,6 +63,38 @@ class ChatOperator {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async deleteConversation(id: string): Promise<AxiosResponse<IChatConversation>> {
|
||||
return await axios.post(
|
||||
`/chatgpt/conversations`,
|
||||
{
|
||||
action: IChatConversationAction.DELETE,
|
||||
id: id
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
baseURL: ENDPOINT_API
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async updateConversation(payload: IChatConversation): Promise<AxiosResponse<IChatConversation>> {
|
||||
return await axios.post(
|
||||
`/chatgpt/conversations`,
|
||||
{
|
||||
action: IChatConversationAction.UPDATE,
|
||||
...payload
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
baseURL: ENDPOINT_API
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const chatOperator = new ChatOperator();
|
||||
Reference in new issue
Block a user