增加 删除助理
更新 文档
This commit is contained in:
parent
31265fc401
commit
ebe075e0c4
@ -265,6 +265,35 @@ paths:
|
|||||||
summary: 创建 Assistant
|
summary: 创建 Assistant
|
||||||
tags:
|
tags:
|
||||||
- assistant
|
- assistant
|
||||||
|
/api/v1/assistants/{id}:
|
||||||
|
delete:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: get string by ID
|
||||||
|
parameters:
|
||||||
|
- description: Assistant ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"204":
|
||||||
|
description: No Content
|
||||||
|
"404":
|
||||||
|
description: Not Found
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
security:
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
summary: 删除 Assistant
|
||||||
|
tags:
|
||||||
|
- assistant
|
||||||
/api/v1/assistants/{id}/tools:
|
/api/v1/assistants/{id}/tools:
|
||||||
get:
|
get:
|
||||||
consumes:
|
consumes:
|
||||||
|
@ -896,6 +896,43 @@ export const AssistantApiAxiosParamCreator = function (configuration?: Configura
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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 删除 Assistant
|
||||||
|
* @param {number} id Assistant ID
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
apiV1AssistantsIdDelete: async (id: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||||
|
// verify required parameter 'id' is not null or undefined
|
||||||
|
assertParamExists('apiV1AssistantsIdDelete', 'id', id)
|
||||||
|
const localVarPath = `/api/v1/assistants/{id}`
|
||||||
|
.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: 'DELETE', ...baseOptions, ...options};
|
||||||
|
const localVarHeaderParameter = {} as any;
|
||||||
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
|
// authentication ApiKeyAuth required
|
||||||
|
await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
||||||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||||
@ -1085,6 +1122,19 @@ export const AssistantApiFp = function(configuration?: Configuration) {
|
|||||||
const localVarOperationServerBasePath = operationServerMap['AssistantApi.apiV1AssistantsGet']?.[localVarOperationServerIndex]?.url;
|
const localVarOperationServerBasePath = operationServerMap['AssistantApi.apiV1AssistantsGet']?.[localVarOperationServerIndex]?.url;
|
||||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* get string by ID
|
||||||
|
* @summary 删除 Assistant
|
||||||
|
* @param {number} id Assistant ID
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async apiV1AssistantsIdDelete(id: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
|
||||||
|
const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1AssistantsIdDelete(id, options);
|
||||||
|
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
||||||
|
const localVarOperationServerBasePath = operationServerMap['AssistantApi.apiV1AssistantsIdDelete']?.[localVarOperationServerIndex]?.url;
|
||||||
|
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* get string by ID
|
* get string by ID
|
||||||
* @summary 获取 Assistant 所绑定的 Tool
|
* @summary 获取 Assistant 所绑定的 Tool
|
||||||
@ -1158,6 +1208,16 @@ export const AssistantApiFactory = function (configuration?: Configuration, base
|
|||||||
apiV1AssistantsGet(options?: any): AxiosPromise<ApiV1AssistantsGet200Response> {
|
apiV1AssistantsGet(options?: any): AxiosPromise<ApiV1AssistantsGet200Response> {
|
||||||
return localVarFp.apiV1AssistantsGet(options).then((request) => request(axios, basePath));
|
return localVarFp.apiV1AssistantsGet(options).then((request) => request(axios, basePath));
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* get string by ID
|
||||||
|
* @summary 删除 Assistant
|
||||||
|
* @param {number} id Assistant ID
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
apiV1AssistantsIdDelete(id: number, options?: any): AxiosPromise<void> {
|
||||||
|
return localVarFp.apiV1AssistantsIdDelete(id, options).then((request) => request(axios, basePath));
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* get string by ID
|
* get string by ID
|
||||||
* @summary 获取 Assistant 所绑定的 Tool
|
* @summary 获取 Assistant 所绑定的 Tool
|
||||||
@ -1221,6 +1281,18 @@ export class AssistantApi extends BaseAPI {
|
|||||||
return AssistantApiFp(this.configuration).apiV1AssistantsGet(options).then((request) => request(this.axios, this.basePath));
|
return AssistantApiFp(this.configuration).apiV1AssistantsGet(options).then((request) => request(this.axios, this.basePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get string by ID
|
||||||
|
* @summary 删除 Assistant
|
||||||
|
* @param {number} id Assistant ID
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
* @memberof AssistantApi
|
||||||
|
*/
|
||||||
|
public apiV1AssistantsIdDelete(id: number, options?: RawAxiosRequestConfig) {
|
||||||
|
return AssistantApiFp(this.configuration).apiV1AssistantsIdDelete(id, options).then((request) => request(this.axios, this.basePath));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get string by ID
|
* get string by ID
|
||||||
* @summary 获取 Assistant 所绑定的 Tool
|
* @summary 获取 Assistant 所绑定的 Tool
|
||||||
|
58
src/pages/assistants/create.vue
Normal file
58
src/pages/assistants/create.vue
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<template>
|
||||||
|
<v-container>
|
||||||
|
<v-row>
|
||||||
|
<v-col cols="12" md="6">
|
||||||
|
<v-card>
|
||||||
|
<v-card-title class="headline">创建助理</v-card-title>
|
||||||
|
<v-card-text>
|
||||||
|
<v-form ref="form">
|
||||||
|
<v-text-field v-model="name" label="助理名称" required></v-text-field>
|
||||||
|
<v-text-field v-model="description" label="描述你的助理" required></v-text-field>
|
||||||
|
<v-textarea v-model="prompt" label="助理提示语" required></v-textarea>
|
||||||
|
<v-btn @click="createAssistant" color="primary">创建</v-btn>
|
||||||
|
</v-form>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="6">
|
||||||
|
<div>
|
||||||
|
<h3>创建你的助理</h3>
|
||||||
|
<p>每个助理可以绑定工具,工具可以让你的助理具有访问外界或者操作一些装置的能力。</p>
|
||||||
|
<p>能用成什么样,取决于你的想象。</p>
|
||||||
|
</div>
|
||||||
|
<div v-if="createdID != 0">
|
||||||
|
<h3>你刚刚创建了一个助理!</h3>
|
||||||
|
<p>你的助理ID是:{{ createdID }}</p>
|
||||||
|
<p>回到助理页面,开始设置它!</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</v-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { api } from '@/plugins/api';
|
||||||
|
|
||||||
|
const name = ref('');
|
||||||
|
const prompt = ref('');
|
||||||
|
const description = ref('');
|
||||||
|
|
||||||
|
const createdID = ref(0);
|
||||||
|
|
||||||
|
const createAssistant = async () => {
|
||||||
|
try {
|
||||||
|
let assistant = await api.Assistant.apiV1AssistantsPost({ name: name.value, prompt: prompt.value, description: description.value });
|
||||||
|
prompt.value = '';
|
||||||
|
createdID.value = assistant.data.data?.id ?? 0;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
// 请求失败,可以在这里添加相应的错误处理逻辑
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
/* 添加样式 */
|
||||||
|
</style>
|
@ -1,6 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<h3>你创建的助理</h3>
|
<h3>你创建的助理</h3>
|
||||||
|
|
||||||
|
<v-btn color="primary" @click="to('/assistants/create')">创建助理</v-btn>
|
||||||
|
|
||||||
<div class="mt-3">
|
<div class="mt-3">
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col
|
<v-col
|
||||||
@ -16,20 +18,76 @@
|
|||||||
<!-- <p>Email: {{ assistant.email }}</p>
|
<!-- <p>Email: {{ assistant.email }}</p>
|
||||||
<p>Phone: {{ assistant.phone }}</p> -->
|
<p>Phone: {{ assistant.phone }}</p> -->
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
|
<v-card-actions>
|
||||||
|
<v-btn color="primary" @click="openDialog(assistant.id)"
|
||||||
|
>对话</v-btn
|
||||||
|
>
|
||||||
|
<!-- <v-btn color="primary" @click="editAssistant(assistant)"
|
||||||
|
>编辑</v-btn
|
||||||
|
> -->
|
||||||
|
<v-btn color="error" @click="deleteAssistant(assistant.id)"
|
||||||
|
>删除</v-btn
|
||||||
|
>
|
||||||
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<v-dialog v-model="dialog" persistent max-width="290">
|
||||||
|
<v-card>
|
||||||
|
<v-card-title class="headline">确认删除</v-card-title>
|
||||||
|
<v-card-text
|
||||||
|
>您确定要删除这个助理吗?</v-card-text
|
||||||
|
>
|
||||||
|
<v-card-actions>
|
||||||
|
<v-spacer></v-spacer>
|
||||||
|
<v-btn color="green darken-1" text @click="dialog = false">取消</v-btn>
|
||||||
|
<v-btn color="red darken-1" text @click="deleteAssistantConfirmed"
|
||||||
|
>删除</v-btn
|
||||||
|
>
|
||||||
|
</v-card-actions>
|
||||||
|
</v-card>
|
||||||
|
</v-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ApiV1AssistantsGet200Response } from "@/api";
|
import { ApiV1AssistantsGet200Response } from "@/api";
|
||||||
import { api } from "@/plugins/api";
|
import { api } from "@/plugins/api";
|
||||||
|
import router from "@/router";
|
||||||
|
|
||||||
let assistants: Ref<ApiV1AssistantsGet200Response> = ref({});
|
let assistants: Ref<ApiV1AssistantsGet200Response> = ref({});
|
||||||
|
|
||||||
api.Assistant.apiV1AssistantsGet().then((res) => {
|
function refresh() {
|
||||||
|
api.Assistant.apiV1AssistantsGet().then((res) => {
|
||||||
assistants.value = res.data;
|
assistants.value = res.data;
|
||||||
console.log(assistants.value);
|
console.log(assistants.value);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
refresh();
|
||||||
|
|
||||||
|
let dialog = ref(false);
|
||||||
|
let selectedAssistantId = ref(0);
|
||||||
|
|
||||||
|
function openDialog(assistantId: number) {
|
||||||
|
dialog.value = true;
|
||||||
|
selectedAssistantId.value = assistantId;
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteAssistant(assistantId: number) {
|
||||||
|
selectedAssistantId.value = assistantId;
|
||||||
|
dialog.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteAssistantConfirmed() {
|
||||||
|
api.Assistant.apiV1AssistantsIdDelete(selectedAssistantId.value).then(() => {
|
||||||
|
refresh();
|
||||||
|
});
|
||||||
|
dialog.value = false;
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
function to(path: string) {
|
||||||
|
router.push(path);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
1
src/typed-router.d.ts
vendored
1
src/typed-router.d.ts
vendored
@ -20,6 +20,7 @@ declare module 'vue-router/auto-routes' {
|
|||||||
export interface RouteNamedMap {
|
export interface RouteNamedMap {
|
||||||
'/': 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/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>>,
|
||||||
'/ping/': RouteRecordInfo<'/ping/', '/ping', Record<never, never>, Record<never, never>>,
|
'/ping/': RouteRecordInfo<'/ping/', '/ping', Record<never, never>, Record<never, never>>,
|
||||||
|
Loading…
Reference in New Issue
Block a user