增加 助理编辑

This commit is contained in:
Twilight 2024-08-05 15:46:57 +08:00
parent 4d591220b9
commit cc702a9279
3 changed files with 43 additions and 6 deletions

View File

@ -1,6 +1,26 @@
<template> <template>
<h3>助理 {{ assistant.data?.name }}</h3> <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"> <div class="mt-3">
<p class="mb-3">已经绑定的工具</p> <p class="mb-3">已经绑定的工具</p>
<v-row> <v-row>
@ -70,11 +90,19 @@ import {
ApiV1AssistantsIdToolsGet200Response, ApiV1AssistantsIdToolsGet200Response,
ApiV1AssistantsPost200Response, ApiV1AssistantsPost200Response,
ApiV1ToolsGet200Response, ApiV1ToolsGet200Response,
RagNewInternalSchemaAssistantUpdateRequest,
} from "@/api"; } from "@/api";
// @ts-ignore // @ts-ignore
const assistantId = router.currentRoute.value.params.id as number; 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 tools: Ref<ApiV1ToolsGet200Response> = ref({});
const bindFailed = ref({ const bindFailed = ref({
show: false, 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(); refresh();
</script> </script>

View File

@ -26,8 +26,8 @@
对话 对话
</v-btn> </v-btn>
<v-btn color="primary" @click="editTool(assistant.id ?? 0)" <v-btn color="primary" @click="editAssistant(assistant.id ?? 0)"
>工具</v-btn >编辑</v-btn
> >
<v-btn color="error" @click="deleteAssistant(assistant.id ?? 0)" <v-btn color="error" @click="deleteAssistant(assistant.id ?? 0)"
>删除</v-btn >删除</v-btn
@ -107,8 +107,8 @@ function deleteAssistantConfirmed() {
refresh(); refresh();
} }
function editTool(assistantId: number) { function editAssistant(assistantId: number) {
router.push(`/assistants/${assistantId}/tools`); router.push(`/assistants/${assistantId}/edit`);
} }
function showChats(assistantId: number) { function showChats(assistantId: number) {

View File

@ -21,7 +21,7 @@ declare module 'vue-router/auto-routes' {
'/': RouteRecordInfo<'/', '/', Record<never, never>, Record<never, never>>, '/': RouteRecordInfo<'/', '/', Record<never, never>, Record<never, never>>,
'/assistants/': RouteRecordInfo<'/assistants/', '/assistants', 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]/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>>, '/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/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>>, '/auth/login': RouteRecordInfo<'/auth/login', '/auth/login', Record<never, never>, Record<never, never>>,