This commit is contained in:
Twilight 2024-08-05 15:33:55 +08:00
parent d2b168fb07
commit 6319bd049e
4 changed files with 148 additions and 50 deletions

View File

@ -112,6 +112,7 @@ definitions:
maxLength: 255 maxLength: 255
type: string type: string
prompt: prompt:
maxLength: 512
type: string type: string
required: required:
- description - description
@ -120,10 +121,13 @@ definitions:
rag-new_internal_schema.AssistantUpdateRequest: rag-new_internal_schema.AssistantUpdateRequest:
properties: properties:
description: description:
maxLength: 255
type: string type: string
name: name:
maxLength: 255
type: string type: string
prompt: prompt:
maxLength: 512
type: string type: string
type: object type: object
rag-new_internal_schema.ChatCreateRequest: rag-new_internal_schema.ChatCreateRequest:
@ -158,6 +162,8 @@ definitions:
type: string type: string
userId: userId:
type: integer type: integer
userName:
type: string
valid: valid:
type: boolean type: boolean
type: object type: object
@ -205,16 +211,7 @@ definitions:
type: string type: string
parameters: parameters:
properties: properties:
properties: properties: {}
properties:
location:
properties:
description:
type: string
type:
type: string
type: object
type: object
type: type:
type: string type: string
type: object type: object
@ -635,6 +632,43 @@ paths:
summary: Delete Chat summary: Delete Chat
tags: tags:
- chat - chat
/api/v1/chats/{id}/clear:
post:
consumes:
- application/json
description: 清空当前聊天记录
parameters:
- description: Chat ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
"400":
description: Bad Request
schema:
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"404":
description: Not Found
schema:
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"409":
description: Conflict
schema:
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: 清空聊天记录
tags:
- chat_message
/api/v1/chats/{id}/messages: /api/v1/chats/{id}/messages:
get: get:
consumes: consumes:

View File

@ -783,6 +783,12 @@ export interface RagNewInternalSchemaCurrentUserResponse {
* @memberof RagNewInternalSchemaCurrentUserResponse * @memberof RagNewInternalSchemaCurrentUserResponse
*/ */
'userId'?: number; 'userId'?: number;
/**
*
* @type {string}
* @memberof RagNewInternalSchemaCurrentUserResponse
*/
'userName'?: string;
/** /**
* *
* @type {boolean} * @type {boolean}
@ -928,10 +934,10 @@ export interface RagNewInternalSchemaToolDiscoveryInputFunctionsInner {
export interface RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParameters { export interface RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParameters {
/** /**
* *
* @type {RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParametersProperties} * @type {object}
* @memberof RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParameters * @memberof RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParameters
*/ */
'properties'?: RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParametersProperties; 'properties'?: object;
/** /**
* *
* @type {string} * @type {string}
@ -939,38 +945,6 @@ export interface RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParameters
*/ */
'type'?: string; 'type'?: string;
} }
/**
*
* @export
* @interface RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParametersProperties
*/
export interface RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParametersProperties {
/**
*
* @type {RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParametersPropertiesLocation}
* @memberof RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParametersProperties
*/
'location'?: RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParametersPropertiesLocation;
}
/**
*
* @export
* @interface RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParametersPropertiesLocation
*/
export interface RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParametersPropertiesLocation {
/**
*
* @type {string}
* @memberof RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParametersPropertiesLocation
*/
'description'?: string;
/**
*
* @type {string}
* @memberof RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParametersPropertiesLocation
*/
'type'?: string;
}
/** /**
* *
* @export * @export
@ -1956,6 +1930,43 @@ export class ChatApi extends BaseAPI {
*/ */
export const ChatMessageApiAxiosParamCreator = function (configuration?: Configuration) { export const ChatMessageApiAxiosParamCreator = function (configuration?: Configuration) {
return { return {
/**
*
* @summary
* @param {number} id Chat ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiV1ChatsIdClearPost: async (id: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'id' is not null or undefined
assertParamExists('apiV1ChatsIdClearPost', 'id', id)
const localVarPath = `/api/v1/chats/{id}/clear`
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication ApiKeyAuth required
await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration)
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/** /**
* get string by ID * get string by ID
* @summary * @summary
@ -2084,6 +2095,19 @@ export const ChatMessageApiAxiosParamCreator = function (configuration?: Configu
export const ChatMessageApiFp = function(configuration?: Configuration) { export const ChatMessageApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = ChatMessageApiAxiosParamCreator(configuration) const localVarAxiosParamCreator = ChatMessageApiAxiosParamCreator(configuration)
return { return {
/**
*
* @summary
* @param {number} id Chat ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiV1ChatsIdClearPost(id: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1ChatsIdClearPost(id, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['ChatMessageApi.apiV1ChatsIdClearPost']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/** /**
* get string by ID * get string by ID
* @summary * @summary
@ -2135,6 +2159,16 @@ export const ChatMessageApiFp = function(configuration?: Configuration) {
export const ChatMessageApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { export const ChatMessageApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = ChatMessageApiFp(configuration) const localVarFp = ChatMessageApiFp(configuration)
return { return {
/**
*
* @summary
* @param {number} id Chat ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiV1ChatsIdClearPost(id: number, options?: any): AxiosPromise<void> {
return localVarFp.apiV1ChatsIdClearPost(id, options).then((request) => request(axios, basePath));
},
/** /**
* get string by ID * get string by ID
* @summary * @summary
@ -2177,6 +2211,18 @@ export const ChatMessageApiFactory = function (configuration?: Configuration, ba
* @extends {BaseAPI} * @extends {BaseAPI}
*/ */
export class ChatMessageApi extends BaseAPI { export class ChatMessageApi extends BaseAPI {
/**
*
* @summary
* @param {number} id Chat ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ChatMessageApi
*/
public apiV1ChatsIdClearPost(id: number, options?: RawAxiosRequestConfig) {
return ChatMessageApiFp(this.configuration).apiV1ChatsIdClearPost(id, options).then((request) => request(this.axios, this.basePath));
}
/** /**
* get string by ID * get string by ID
* @summary * @summary

View File

@ -1,17 +1,17 @@
<template> <template>
<div> <div>
<h3>助理 {{ assistant.data?.name }}</h3> <h3>助理 {{ assistant.data?.name }}</h3>
<v-btn @click="dialog = true">创建聊天</v-btn> <v-btn color="primary" @click="dialog = true">创建聊天</v-btn>
<div class="mt-3"> <div class="mt-3">
<v-slide-y-transition group tag="v-list"> <v-slide-y-transition group tag="v-list">
<v-list-item v-for="chat in chats.data" :key="chat.id"> <v-list-item v-for="c in chats.data" :key="c.id">
<template v-slot:prepend> <template #prepend>
<v-avatar> <v-avatar>
<v-icon>mdi-account</v-icon> <v-icon>mdi-account</v-icon>
</v-avatar> </v-avatar>
</template> </template>
<v-list-item-title>{{ chat.name }}</v-list-item-title> <v-list-item-title>{{ c.name }}</v-list-item-title>
<v-list-item-subtitle>{{ chat.created_at }}</v-list-item-subtitle> <v-list-item-subtitle>{{ c.created_at }}</v-list-item-subtitle>
</v-list-item> </v-list-item>
</v-slide-y-transition> </v-slide-y-transition>
</div> </div>
@ -68,7 +68,7 @@ function getChats() {
} }
function createChat() { function createChat() {
api.Chat.apiV1ChatsPost(chat.value).then((res) => { api.Chat.apiV1ChatsPost(chat.value).then(() => {
getChats(); getChats();
dialog.value = false; dialog.value = false;
}); });

View File

@ -59,6 +59,8 @@
@keyup.enter="sendMessage" @keyup.enter="sendMessage"
></v-text-field> ></v-text-field>
<v-btn color="primary" @click="sendMessage">发送</v-btn> <v-btn color="primary" @click="sendMessage">发送</v-btn>
<v-btn class="ml-2" color="primary" @click="clearMessages">清空</v-btn>
<v-btn class="ml-2" color="primary" @click="deleteChat">删除</v-btn>
</div> </div>
</div> </div>
</template> </template>
@ -68,6 +70,9 @@ import { ApiV1ChatsIdMessagesGet200Response } from "@/api";
import { ref } from "vue"; import { ref } from "vue";
import { api, conf } from "@/plugins/api"; import { api, conf } from "@/plugins/api";
import VueMarkdown from "vue-markdown-render"; import VueMarkdown from "vue-markdown-render";
import router from "@/router";
import { useChatStore } from "@/stores/chat";
const chatStore = useChatStore();
// @ts-ignore // @ts-ignore
const chatId = parseInt(useRoute().params.id as string); const chatId = parseInt(useRoute().params.id as string);
@ -199,5 +204,18 @@ const getMessages = () => {
}); });
}; };
const clearMessages = () => {
api.ChatMessage.apiV1ChatsIdClearPost(chatId).then(() => {
getMessages();
});
};
const deleteChat = () => {
api.Chat.apiV1ChatsIdDelete(chatId).then(() => {
chatStore.getChats();
router.push("/assistants");
});
};
getMessages(); getMessages();
</script> </script>