Refine chatdoc and base code interface (#2)
This commit is contained in:
1 parent
28da0263dc
commit
09ee60aa6e
21 files changed
+352
-168
No files matched your search
@@ -5,7 +5,7 @@ import { getBaseUrlAuth } from '@/utils';
|
||||
|
||||
class AuthOperator {
|
||||
async refreshToken(payload: IToken): Promise<AxiosResponse<ITokenResponse>> {
|
||||
return httpClient.post('/token/refresh/', payload);
|
||||
return httpClient.post('/auth/refresh/', payload);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
IChatdocRepositoriesResponse,
|
||||
IChatdocRepositoryResponse
|
||||
} from '@/models';
|
||||
import { ACTION_RETRIEVE_ALL, ACTION_UPDATE, BASE_URL_API } from '@/constants';
|
||||
import { ACTION_UPDATE, BASE_URL_API } from '@/constants';
|
||||
import { ACTION_CREATE, ACTION_DELETE, ACTION_RETRIEVE, ACTION_RETRIEVE_BATCH } from '@/constants';
|
||||
|
||||
class ChatdocOperator {
|
||||
@@ -77,7 +77,7 @@ class ChatdocOperator {
|
||||
return await axios.post(
|
||||
`/chatdoc/repositories`,
|
||||
{
|
||||
action: ACTION_RETRIEVE_ALL
|
||||
action: ACTION_RETRIEVE_BATCH
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
@@ -97,7 +97,7 @@ class ChatdocOperator {
|
||||
return await axios.post(
|
||||
`/chatdoc/documents`,
|
||||
{
|
||||
action: ACTION_RETRIEVE_ALL,
|
||||
action: ACTION_RETRIEVE_BATCH,
|
||||
repository_id: repositoryId
|
||||
},
|
||||
{
|
||||
@@ -111,15 +111,19 @@ class ChatdocOperator {
|
||||
);
|
||||
}
|
||||
|
||||
async getAllConversations(repositoryId: string): Promise<AxiosResponse<IChatdocConversationsResponse>> {
|
||||
async getAllConversations(
|
||||
repositoryId: string,
|
||||
options: { token: string }
|
||||
): Promise<AxiosResponse<IChatdocConversationsResponse>> {
|
||||
return await axios.post(
|
||||
`/chatdoc/conversations`,
|
||||
{
|
||||
action: ACTION_RETRIEVE_ALL,
|
||||
action: ACTION_RETRIEVE_BATCH,
|
||||
repository_id: repositoryId
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: `Bearer ${options.token}`,
|
||||
accept: 'application/json',
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
@@ -273,16 +277,16 @@ class ChatdocOperator {
|
||||
);
|
||||
}
|
||||
|
||||
async chat(
|
||||
payload: { repositoryId: string; question: string; conversationId?: string; knowledgeFallback?: boolean },
|
||||
async chatConversation(
|
||||
payload: { repositoryId: string; question: string; id?: string; knowledgeFallback?: boolean },
|
||||
options: { token: string; stream: (response: IChatdocChatResponse) => void }
|
||||
): Promise<AxiosResponse<IChatdocChatResponse>> {
|
||||
return await axios.post(
|
||||
`/chatdoc/chat`,
|
||||
`/chatdoc/conversations`,
|
||||
{
|
||||
repository_id: payload.repositoryId,
|
||||
question: payload.question,
|
||||
conversation_id: payload.conversationId,
|
||||
id: payload.id,
|
||||
stateful: true
|
||||
},
|
||||
{
|
||||
|
||||
@@ -10,25 +10,25 @@ export interface IInviteesQuery {
|
||||
|
||||
class UserOperator {
|
||||
async getMe(): Promise<AxiosResponse<IUserDetailResponse>> {
|
||||
return httpClient.get('/me');
|
||||
return httpClient.get('/users/me');
|
||||
}
|
||||
|
||||
async getInvitees(query: IInviteesQuery): Promise<AxiosResponse<IUserListResponse>> {
|
||||
return httpClient.get('/me/invitees', {
|
||||
return httpClient.get('/users/me/invitees', {
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
async updateMe(data: IUser): Promise<AxiosResponse<IUserDetailResponse>> {
|
||||
return httpClient.put('/me', data);
|
||||
return httpClient.put('/users/me', data);
|
||||
}
|
||||
|
||||
async getVerify(): Promise<AxiosResponse<IUserDetailResponse>> {
|
||||
return httpClient.get('/verify');
|
||||
return httpClient.get('/users/verify');
|
||||
}
|
||||
|
||||
async updateVerify(data: IUser): Promise<AxiosResponse<IUserDetailResponse>> {
|
||||
return httpClient.put('/verify', data);
|
||||
return httpClient.put('/users/verify', data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user