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
type: string
prompt:
maxLength: 512
type: string
required:
- description
@ -120,10 +121,13 @@ definitions:
rag-new_internal_schema.AssistantUpdateRequest:
properties:
description:
maxLength: 255
type: string
name:
maxLength: 255
type: string
prompt:
maxLength: 512
type: string
type: object
rag-new_internal_schema.ChatCreateRequest:
@ -158,6 +162,8 @@ definitions:
type: string
userId:
type: integer
userName:
type: string
valid:
type: boolean
type: object
@ -205,16 +211,7 @@ definitions:
type: string
parameters:
properties:
properties:
properties:
location:
properties:
description:
type: string
type:
type: string
type: object
type: object
properties: {}
type:
type: string
type: object
@ -635,6 +632,43 @@ paths:
summary: Delete Chat
tags:
- 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:
get:
consumes:

View File

@ -783,6 +783,12 @@ export interface RagNewInternalSchemaCurrentUserResponse {
* @memberof RagNewInternalSchemaCurrentUserResponse
*/
'userId'?: number;
/**
*
* @type {string}
* @memberof RagNewInternalSchemaCurrentUserResponse
*/
'userName'?: string;
/**
*
* @type {boolean}
@ -928,10 +934,10 @@ export interface RagNewInternalSchemaToolDiscoveryInputFunctionsInner {
export interface RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParameters {
/**
*
* @type {RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParametersProperties}
* @type {object}
* @memberof RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParameters
*/
'properties'?: RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParametersProperties;
'properties'?: object;
/**
*
* @type {string}
@ -939,38 +945,6 @@ export interface RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParameters
*/
'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
@ -1956,6 +1930,43 @@ export class ChatApi extends BaseAPI {
*/
export const ChatMessageApiAxiosParamCreator = function (configuration?: Configuration) {
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
* @summary
@ -2084,6 +2095,19 @@ export const ChatMessageApiAxiosParamCreator = function (configuration?: Configu
export const ChatMessageApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = ChatMessageApiAxiosParamCreator(configuration)
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
* @summary
@ -2135,6 +2159,16 @@ export const ChatMessageApiFp = function(configuration?: Configuration) {
export const ChatMessageApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = ChatMessageApiFp(configuration)
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
* @summary
@ -2177,6 +2211,18 @@ export const ChatMessageApiFactory = function (configuration?: Configuration, ba
* @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
* @summary

View File

@ -1,17 +1,17 @@
<template>
<div>
<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">
<v-slide-y-transition group tag="v-list">
<v-list-item v-for="chat in chats.data" :key="chat.id">
<template v-slot:prepend>
<v-list-item v-for="c in chats.data" :key="c.id">
<template #prepend>
<v-avatar>
<v-icon>mdi-account</v-icon>
</v-avatar>
</template>
<v-list-item-title>{{ chat.name }}</v-list-item-title>
<v-list-item-subtitle>{{ chat.created_at }}</v-list-item-subtitle>
<v-list-item-title>{{ c.name }}</v-list-item-title>
<v-list-item-subtitle>{{ c.created_at }}</v-list-item-subtitle>
</v-list-item>
</v-slide-y-transition>
</div>
@ -68,7 +68,7 @@ function getChats() {
}
function createChat() {
api.Chat.apiV1ChatsPost(chat.value).then((res) => {
api.Chat.apiV1ChatsPost(chat.value).then(() => {
getChats();
dialog.value = false;
});

View File

@ -59,6 +59,8 @@
@keyup.enter="sendMessage"
></v-text-field>
<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>
</template>
@ -68,6 +70,9 @@ import { ApiV1ChatsIdMessagesGet200Response } from "@/api";
import { ref } from "vue";
import { api, conf } from "@/plugins/api";
import VueMarkdown from "vue-markdown-render";
import router from "@/router";
import { useChatStore } from "@/stores/chat";
const chatStore = useChatStore();
// @ts-ignore
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();
</script>