add clear

This commit is contained in:
Chuck1sn
2025-06-14 13:54:31 +08:00
parent ab72508408
commit f559e4cde3
4 changed files with 1876 additions and 1802 deletions

View File

@@ -747,6 +747,19 @@
}
}
},
"/ai/chat/refresh": {
"post": {
"tags": [
"ai-controller"
],
"operationId": "createNewConversation",
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/ai/action/search": {
"post": {
"tags": [
@@ -1627,10 +1640,6 @@
"name": {
"type": "string"
},
"parentId": {
"type": "integer",
"format": "int64"
},
"isBound": {
"type": "boolean"
}
@@ -1641,6 +1650,14 @@
"properties": {
"username": {
"type": "string"
},
"startDate": {
"type": "string",
"format": "date-time"
},
"endDate": {
"type": "string",
"format": "date-time"
}
}
},

View File

@@ -372,6 +372,22 @@ export interface paths {
patch?: never;
trace?: never;
};
"/ai/chat/refresh": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
put?: never;
post: operations["createNewConversation"];
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/ai/action/search": {
parameters: {
query?: never;
@@ -730,12 +746,14 @@ export interface components {
/** Format: int64 */
id: number;
name: string;
/** Format: int64 */
parentId?: number;
isBound?: boolean;
};
UserQueryDto: {
username?: string;
/** Format: date-time */
startDate?: string;
/** Format: date-time */
endDate?: string;
};
PageResponseDtoListUserRolePermissionDto: {
/** Format: int64 */
@@ -1512,6 +1530,24 @@ export interface operations {
};
};
};
createNewConversation: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content?: never;
};
};
};
searchAction: {
parameters: {
query?: never;

View File

@@ -20,7 +20,7 @@
<button
v-if="chatElement.type === 'action' && (chatElement.command === 'CREATE_USER' || chatElement.command === 'CREATE_DEPARTMENT')"
type="button" @click="commandActionMap[chatElement.command!]"
class="px-3 py-2 text-sm font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
class="px-3 py-2 text-sm font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300">
{{
commandContentMap[chatElement.command!]
}}</button>
@@ -38,6 +38,14 @@
</div>
<form class="sticky">
<button @click.prevent="clearConversation"
class="relative inline-flex items-center justify-center p-0.5 mb-2 me-2
overflow-hidden text-sm font-medium text-gray-900 rounded-lg group bg-gradient-to-br from-purple-600 to-blue-500 group-hover:from-purple-600 group-hover:to-blue-500 hover:text-white focus:ring-4 focus:outline-none focus:ring-blue-300 ">
<span
class="relative px-3 py-2 text-xs font-medium transition-all ease-in duration-75 bg-white rounded-md group-hover:bg-transparent">
开启新对话
</span>
</button>
<div class="w-full border border-gray-200 rounded-lg bg-gray-50">
<div class="px-4 py-2 bg-white rounded-t-lg">
<label for="comment" class="sr-only"></label>
@@ -103,7 +111,7 @@ import useUserStore from "../composables/store/useUserStore";
import { useUserUpsert } from "../composables/user/useUserUpsert";
import type { UserUpsertSubmitModel } from "../types/user";
const { messages, chat, isLoading, cancel, searchAction, executeAction } =
const { messages, chat, isLoading, cancel, searchAction, executeAction, clearConversation } =
useAiChat();
const { user } = useUserStore();
const userUpsertModal = ref<ModalInterface>();

View File

@@ -117,6 +117,11 @@ export const useAiChat = () => {
}
};
const clearConversation = async () => {
await client.POST("/ai/chat/refresh");
messages.value = [];
};
const cancel = () => {
if (currentController) {
currentController.abort();
@@ -124,5 +129,13 @@ export const useAiChat = () => {
}
};
return { messages, chat, isLoading, cancel, searchAction, executeAction };
return {
messages,
chat,
isLoading,
cancel,
searchAction,
executeAction,
clearConversation,
};
};