This commit is contained in:
Twilight 2024-08-04 01:02:02 +08:00
parent 35ff1fd73e
commit a94d07f05d
11 changed files with 8490 additions and 691 deletions

View File

@ -447,6 +447,11 @@ paths:
consumes:
- application/json
description: get string by ID
parameters:
- description: Assistant ID
in: query
name: assistant_id
type: integer
produces:
- application/json
responses:

7276
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -10,6 +10,7 @@
},
"dependencies": {
"@mdi/font": "7.4.47",
"@openapitools/openapi-generator-cli": "^2.13.4",
"axios": "^1.7.2",
"core-js": "^3.37.1",
"eslint-plugin-prettier": "^5.2.1",

View File

@ -1476,10 +1476,11 @@ export const ChatApiAxiosParamCreator = function (configuration?: Configuration)
/**
* get string by ID
* @summary Chat
* @param {number} [assistantId] Assistant ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiV1ChatsGet: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
apiV1ChatsGet: async (assistantId?: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/v1/chats`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
@ -1492,6 +1493,10 @@ export const ChatApiAxiosParamCreator = function (configuration?: Configuration)
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
if (assistantId !== undefined) {
localVarQueryParameter['assistant_id'] = assistantId;
}
setSearchParams(localVarUrlObj, localVarQueryParameter);
@ -1589,11 +1594,12 @@ export const ChatApiFp = function(configuration?: Configuration) {
/**
* get string by ID
* @summary Chat
* @param {number} [assistantId] Assistant ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiV1ChatsGet(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ApiV1ChatsGet200Response>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1ChatsGet(options);
async apiV1ChatsGet(assistantId?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ApiV1ChatsGet200Response>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1ChatsGet(assistantId, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['ChatApi.apiV1ChatsGet']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
@ -1637,11 +1643,12 @@ export const ChatApiFactory = function (configuration?: Configuration, basePath?
/**
* get string by ID
* @summary Chat
* @param {number} [assistantId] Assistant ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiV1ChatsGet(options?: any): AxiosPromise<ApiV1ChatsGet200Response> {
return localVarFp.apiV1ChatsGet(options).then((request) => request(axios, basePath));
apiV1ChatsGet(assistantId?: number, options?: any): AxiosPromise<ApiV1ChatsGet200Response> {
return localVarFp.apiV1ChatsGet(assistantId, options).then((request) => request(axios, basePath));
},
/**
* get string by ID
@ -1676,12 +1683,13 @@ export class ChatApi extends BaseAPI {
/**
* get string by ID
* @summary Chat
* @param {number} [assistantId] Assistant ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ChatApi
*/
public apiV1ChatsGet(options?: RawAxiosRequestConfig) {
return ChatApiFp(this.configuration).apiV1ChatsGet(options).then((request) => request(this.axios, this.basePath));
public apiV1ChatsGet(assistantId?: number, options?: RawAxiosRequestConfig) {
return ChatApiFp(this.configuration).apiV1ChatsGet(assistantId, options).then((request) => request(this.axios, this.basePath));
}
/**

View File

@ -0,0 +1,81 @@
<template>
<div>
<h3>助理 {{ assistant.data?.name }}</h3>
<v-btn @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-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>
</v-slide-y-transition>
</div>
</div>
<v-dialog v-model="dialog" max-width="500px">
<v-card>
<v-card-title>创建聊天</v-card-title>
<v-card-text>
<v-text-field v-model="chat.name" label="聊天名称" />
</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn @click="dialog = false">取消</v-btn>
<v-btn color="primary" @click="createChat">创建</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script setup lang="ts">
import { ref } from "vue"
import { api } from "@/plugins/api"
import { ApiV1AssistantsPost200Response, ApiV1ChatsGet200Response, RagNewInternalSchemaChatCreateRequest } from "@/api"
import router from "@/router"
import { useChatStore } from '../../../stores/chat'
// @ts-ignore
const assistantId = router.currentRoute.value.params.id as number
const assistant: Ref<ApiV1AssistantsPost200Response> = ref({})
const chats = ref<ApiV1ChatsGet200Response>({})
const dialog = ref(false)
const chat: Ref<RagNewInternalSchemaChatCreateRequest> = ref({
name: '',
assistant_id: parseInt(assistantId.toString()),
})
const chatStore = useChatStore()
function getAssistant() {
api.Assistant.apiV1AssistantsIdGet(assistantId).then((res) => {
assistant.value = res.data
})
}
function getChats() {
api.Chat.apiV1ChatsGet(assistantId).then((res) => {
chats.value = res.data
})
}
function createChat() {
api.Chat.apiV1ChatsPost(chat.value).then((res) => {
getChats()
dialog.value = false
})
chatStore.getChats()
}
getAssistant()
getChats()
</script>

View File

@ -1,8 +1,8 @@
<template>
<h3>助理 {{ assistant.data?.name }}</h3>
<h3 class="text-2xl font-bold leading-7 text-gray-900 sm:truncate sm:text-3xl sm:tracking-tight">助理 {{ assistant.data?.name }}</h3>
<div class="mt-3">
<p>已经绑定的工具</p>
<p class="mb-3">已经绑定的工具</p>
<v-row>
<v-col
v-for="tool in bindedTools.data"

View File

@ -1,10 +1,11 @@
<template>
<h3>你创建的助理</h3>
<v-btn color="primary" @click="to('/assistants/create')">创建助理</v-btn>
<v-btn color="primary" class="mt-3 mb-3" @click="to('/assistants/create')">创建助理</v-btn>
<div class="mt-3">
<v-row><v-slide-x-transition group>
<v-row>
<v-slide-x-transition group>
<v-col v-for="assistant in assistants.data" :key="assistant.id" cols="12" md="4" sm="6">
<v-card>
<v-card-title>{{ assistant.name }}</v-card-title>
@ -13,16 +14,17 @@
<p>Phone: {{ assistant.phone }}</p> -->
</v-card-text>
<v-card-actions>
<!-- <v-btn color="primary" @click="openDialog(assistant.id ?? 0)"
>对话</v-btn
> -->
<v-btn color="primary" @click="showChats(assistant.id ?? 0)">
对话
</v-btn>
<v-btn color="primary" @click="editTool(assistant.id ?? 0)">工具</v-btn>
<v-btn color="error" @click="deleteAssistant(assistant.id ?? 0)">删除</v-btn>
</v-card-actions>
</v-card>
</v-col>
</v-slide-x-transition></v-row>
</v-slide-x-transition>
</v-row>
</div>
<v-dialog v-model="dialog" max-width="290" persistent>
@ -93,6 +95,11 @@ function editTool(assistantId: number) {
router.push(`/assistants/${assistantId}/tools`)
}
function showChats(assistantId: number) {
router.push(`/assistants/${assistantId}/chats`)
}
function to(path: string) {
router.push(path)
}

View File

@ -1,7 +1,7 @@
<template>
<h3>Ping 与服务器连通性测试</h3>
<div>
<v-btn @click="greet()">Greet</v-btn>
<div class="mt-3 mb-3">
<v-btn color="primary" @click="greet()">Greet</v-btn>
</div>
<p v-if="response != ''">服务器回应{{ response }}</p>

View File

@ -1,11 +1,11 @@
<template>
<h3>工具</h3>
<v-btn color="primary" @click="to('/tools/create')">创建工具</v-btn>
<v-btn color="primary" @click="to('/tools/create')" class="mt-3 mb-3">创建工具</v-btn>
<div class="mt-3">
<v-row
><v-slide-x-transition group>
<v-row>
<v-slide-x-transition group>
<v-col
v-for="tool in tools.data"
:key="tool.id"
@ -24,14 +24,14 @@
<!-- <v-btn color="primary" @click="editAssistant(assistant)"
>编辑</v-btn
> -->
<v-btn color="error" @click="deleteTool(tool.id ?? 0)"
>删除</v-btn
>
<v-btn color="error" @click="deleteTool(tool.id ?? 0)">
删除
</v-btn>
</v-card-actions>
</v-card>
</v-col>
</v-slide-x-transition></v-row
>
</v-slide-x-transition>
</v-row>
</div>
<v-dialog v-model="dialog" max-width="290" persistent>
@ -52,9 +52,7 @@
<v-card-text>{{ failedDialog.message }}</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="green darken-1" @click="failedDialog.show = false"
>关闭</v-btn
>
<v-btn color="green darken-1" @click="failedDialog.show = false">关闭</v-btn>
</v-card-actions>
</v-card>
</v-dialog>

View File

@ -20,6 +20,7 @@ declare module 'vue-router/auto-routes' {
export interface RouteNamedMap {
'/': 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/binds': RouteRecordInfo<'/assistants/binds', '/assistants/binds', Record<never, never>, Record<never, never>>,
'/assistants/create': RouteRecordInfo<'/assistants/create', '/assistants/create', Record<never, never>, Record<never, never>>,

1748
yarn.lock

File diff suppressed because it is too large Load Diff