Merge branch 'main' of repo.leafdev.top:leaf/amber-web
This commit is contained in:
commit
2699b14b63
@ -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:
|
||||
|
114
src/api/api.ts
114
src/api/api.ts
@ -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 查看聊天记录
|
||||
|
@ -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;
|
||||
});
|
||||
|
@ -1,6 +1,26 @@
|
||||
<template>
|
||||
<h3>助理 {{ assistant.data?.name }}</h3>
|
||||
|
||||
<v-text-field
|
||||
v-if="assistant.data != null"
|
||||
v-model="assistant.data.name"
|
||||
label="助理名称"
|
||||
required
|
||||
></v-text-field>
|
||||
<v-text-field
|
||||
v-if="assistant.data != null"
|
||||
v-model="assistant.data.description"
|
||||
label="描述你的助理"
|
||||
required
|
||||
></v-text-field>
|
||||
<v-textarea
|
||||
v-if="assistant.data != null"
|
||||
v-model="assistant.data.prompt"
|
||||
label="助理提示语"
|
||||
required
|
||||
></v-textarea>
|
||||
<v-btn color="primary" @click="updateAssistant">编辑</v-btn>
|
||||
|
||||
<div class="mt-3">
|
||||
<p class="mb-3">已经绑定的工具</p>
|
||||
<v-row>
|
||||
@ -70,11 +90,19 @@ import {
|
||||
ApiV1AssistantsIdToolsGet200Response,
|
||||
ApiV1AssistantsPost200Response,
|
||||
ApiV1ToolsGet200Response,
|
||||
RagNewInternalSchemaAssistantUpdateRequest,
|
||||
} from "@/api";
|
||||
|
||||
// @ts-ignore
|
||||
const assistantId = router.currentRoute.value.params.id as number;
|
||||
const assistant: Ref<ApiV1AssistantsPost200Response> = ref({});
|
||||
const assistant: Ref<ApiV1AssistantsPost200Response> = ref({
|
||||
data: {
|
||||
name: "",
|
||||
description: "",
|
||||
prompt: "",
|
||||
},
|
||||
});
|
||||
|
||||
const tools: Ref<ApiV1ToolsGet200Response> = ref({});
|
||||
const bindFailed = ref({
|
||||
show: false,
|
||||
@ -127,5 +155,14 @@ function bindTool(toolId: number) {
|
||||
});
|
||||
}
|
||||
|
||||
function updateAssistant() {
|
||||
const assistantUpdate: RagNewInternalSchemaAssistantUpdateRequest = {
|
||||
description: assistant.value.data?.description,
|
||||
name: assistant.value.data?.name,
|
||||
prompt: assistant.value.data?.prompt,
|
||||
};
|
||||
api.Assistant.apiV1AssistantsIdPatch(assistantId, assistantUpdate);
|
||||
}
|
||||
|
||||
refresh();
|
||||
</script>
|
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<h3>你创建的助理</h3>
|
||||
|
||||
<v-btn color="primary" class="mt-3 mb-3" @click="to('/assistants/create')"
|
||||
<v-btn class="mt-3 mb-3" color="primary" @click="to('/assistants/create')"
|
||||
>创建助理</v-btn
|
||||
>
|
||||
|
||||
@ -26,8 +26,8 @@
|
||||
对话
|
||||
</v-btn>
|
||||
|
||||
<v-btn color="primary" @click="editTool(assistant.id ?? 0)"
|
||||
>工具</v-btn
|
||||
<v-btn color="primary" @click="editAssistant(assistant.id ?? 0)"
|
||||
>编辑</v-btn
|
||||
>
|
||||
<v-btn color="error" @click="deleteAssistant(assistant.id ?? 0)"
|
||||
>删除</v-btn
|
||||
@ -107,8 +107,8 @@ function deleteAssistantConfirmed() {
|
||||
refresh();
|
||||
}
|
||||
|
||||
function editTool(assistantId: number) {
|
||||
router.push(`/assistants/${assistantId}/tools`);
|
||||
function editAssistant(assistantId: number) {
|
||||
router.push(`/assistants/${assistantId}/edit`);
|
||||
}
|
||||
|
||||
function showChats(assistantId: number) {
|
||||
|
@ -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>
|
||||
|
2
src/typed-router.d.ts
vendored
2
src/typed-router.d.ts
vendored
@ -21,7 +21,7 @@ declare module 'vue-router/auto-routes' {
|
||||
'/': RouteRecordInfo<'/', '/', Record<never, never>, Record<never, never>>,
|
||||
'/assistants/': RouteRecordInfo<'/assistants/', '/assistants', Record<never, never>, Record<never, never>>,
|
||||
'/assistants/[id]/chats': RouteRecordInfo<'/assistants/[id]/chats', '/assistants/:id/chats', { id: ParamValue<true> }, { id: ParamValue<false> }>,
|
||||
'/assistants/[id]/tools': RouteRecordInfo<'/assistants/[id]/tools', '/assistants/:id/tools', { id: ParamValue<true> }, { id: ParamValue<false> }>,
|
||||
'/assistants/[id]/edit': RouteRecordInfo<'/assistants/[id]/edit', '/assistants/:id/edit', { id: ParamValue<true> }, { id: ParamValue<false> }>,
|
||||
'/assistants/create': RouteRecordInfo<'/assistants/create', '/assistants/create', Record<never, never>, Record<never, never>>,
|
||||
'/auth/callback': RouteRecordInfo<'/auth/callback', '/auth/callback', Record<never, never>, Record<never, never>>,
|
||||
'/auth/login': RouteRecordInfo<'/auth/login', '/auth/login', Record<never, never>, Record<never, never>>,
|
||||
|
Loading…
Reference in New Issue
Block a user