diff --git a/api/swagger.yaml b/api/swagger.yaml index 0e17016..d42eaa5 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -86,6 +86,9 @@ definitions: entity.ChatMessage: properties: assistant_id: + description: AssistantId 可以让同一个对话中,使用不同的助手来处理消息 + type: integer + chat_id: type: integer completion_tokens: type: integer @@ -124,15 +127,6 @@ definitions: type: boolean created_at: type: string - file: - $ref: '#/definitions/entity.File' - file_hash: - description: |- - FileHash 是 File 结构体的 hash,用于判断文件内容是否发生变化 - 只不过一般情况也不会改变,因为 File 就不会变 - type: string - file_id: - type: integer id: description: Id schema.EntityId `gorm:"primarykey" json:"id,string"` type: integer @@ -339,6 +333,8 @@ definitions: type: object schema.ChatMessageAddRequest: properties: + assistant_id: + type: integer message: maxLength: 255 type: string @@ -383,6 +379,18 @@ definitions: - guest_id - name type: object + schema.ChatUpdateRequest: + properties: + assistant_id: + type: integer + expired_at: + $ref: '#/definitions/schema.CustomTime' + name: + maxLength: 30 + type: string + required: + - name + type: object schema.CurrentUserResponse: properties: ip: @@ -401,6 +409,16 @@ definitions: time.Time: type: string type: object + schema.DocumentCreateRequest: + properties: + content: + type: string + name: + type: string + required: + - content + - name + type: object schema.FunctionsInput: properties: description: @@ -1406,6 +1424,88 @@ paths: summary: Delete Chat tags: - chat + get: + consumes: + - application/json + description: 将返回一个实体 + parameters: + - in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/schema.ResponseBody' + - properties: + data: + $ref: '#/definitions/entity.Chat' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/schema.ResponseBody' + "404": + description: Not Found + schema: + $ref: '#/definitions/schema.ResponseBody' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/schema.ResponseBody' + security: + - ApiKeyAuth: [] + summary: 显示一个对话的数据 + tags: + - chat + put: + consumes: + - application/json + description: 可以重新设置对话的一些信息 + parameters: + - in: path + name: id + required: true + type: integer + - description: ChatUpdateRequest + in: body + name: schema.ChatUpdateRequest + required: true + schema: + $ref: '#/definitions/schema.ChatUpdateRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/schema.ResponseBody' + - properties: + data: + $ref: '#/definitions/entity.Chat' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/schema.ResponseBody' + "404": + description: Not Found + schema: + $ref: '#/definitions/schema.ResponseBody' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/schema.ResponseBody' + security: + - ApiKeyAuth: [] + summary: 更新对话 + tags: + - chat /api/v1/chats/{id}/clear: post: consumes: @@ -1803,6 +1903,33 @@ paths: summary: 列出资料库以及资料库下的文档 tags: - libraries + post: + consumes: + - application/json + parameters: + - in: path + name: id + type: integer + - description: schema.DocumentCreateRequest + in: body + name: schema.DocumentCreateRequest + required: true + schema: + $ref: '#/definitions/schema.DocumentCreateRequest' + produces: + - application/json + responses: + "204": + description: No Content + "400": + description: Bad Request + schema: + $ref: '#/definitions/schema.ResponseBody' + security: + - ApiKeyAuth: [] + summary: 创建文档 + tags: + - libraries /api/v1/libraries/{id}/documents/{document_id}: delete: consumes: diff --git a/src/api/api.ts b/src/api/api.ts index 66833db..edab5df 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -839,11 +839,17 @@ export interface EntityChat { */ export interface EntityChatMessage { /** - * + * AssistantId 可以让同一个对话中,使用不同的助手来处理消息 * @type {number} * @memberof EntityChatMessage */ 'assistant_id'?: number; + /** + * + * @type {number} + * @memberof EntityChatMessage + */ + 'chat_id'?: number; /** * * @type {number} @@ -941,24 +947,6 @@ export interface EntityDocument { * @memberof EntityDocument */ 'created_at'?: string; - /** - * - * @type {EntityFile} - * @memberof EntityDocument - */ - 'file'?: EntityFile; - /** - * FileHash 是 File 结构体的 hash,用于判断文件内容是否发生变化 只不过一般情况也不会改变,因为 File 就不会变 - * @type {string} - * @memberof EntityDocument - */ - 'file_hash'?: string; - /** - * - * @type {number} - * @memberof EntityDocument - */ - 'file_id'?: number; /** * Id schema.EntityId `gorm:\"primarykey\" json:\"id,string\"` * @type {number} @@ -1419,6 +1407,12 @@ export interface SchemaChatCreateRequest { * @interface SchemaChatMessageAddRequest */ export interface SchemaChatMessageAddRequest { + /** + * + * @type {number} + * @memberof SchemaChatMessageAddRequest + */ + 'assistant_id'?: number; /** * * @type {string} @@ -1501,6 +1495,31 @@ export interface SchemaChatPublicRequest { */ 'name': string; } +/** + * + * @export + * @interface SchemaChatUpdateRequest + */ +export interface SchemaChatUpdateRequest { + /** + * + * @type {number} + * @memberof SchemaChatUpdateRequest + */ + 'assistant_id'?: number; + /** + * + * @type {SchemaCustomTime} + * @memberof SchemaChatUpdateRequest + */ + 'expired_at'?: SchemaCustomTime; + /** + * + * @type {string} + * @memberof SchemaChatUpdateRequest + */ + 'name': string; +} /** * * @export @@ -1551,6 +1570,25 @@ export interface SchemaCustomTime { */ 'time.Time'?: string; } +/** + * + * @export + * @interface SchemaDocumentCreateRequest + */ +export interface SchemaDocumentCreateRequest { + /** + * + * @type {string} + * @memberof SchemaDocumentCreateRequest + */ + 'content': string; + /** + * + * @type {string} + * @memberof SchemaDocumentCreateRequest + */ + 'name': string; +} /** * * @export @@ -3159,6 +3197,86 @@ export const ChatApiAxiosParamCreator = function (configuration?: Configuration) options: localVarRequestOptions, }; }, + /** + * 将返回一个实体 + * @summary 显示一个对话的数据 + * @param {number} id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ChatsIdGet: async (id: number, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('apiV1ChatsIdGet', 'id', id) + const localVarPath = `/api/v1/chats/{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: 'GET', ...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, + }; + }, + /** + * 可以重新设置对话的一些信息 + * @summary 更新对话 + * @param {number} id + * @param {SchemaChatUpdateRequest} schemaChatUpdateRequest ChatUpdateRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ChatsIdPut: async (id: number, schemaChatUpdateRequest: SchemaChatUpdateRequest, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('apiV1ChatsIdPut', 'id', id) + // verify required parameter 'schemaChatUpdateRequest' is not null or undefined + assertParamExists('apiV1ChatsIdPut', 'schemaChatUpdateRequest', schemaChatUpdateRequest) + const localVarPath = `/api/v1/chats/{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: 'PUT', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication ApiKeyAuth required + await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(schemaChatUpdateRequest, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, /** * get string by ID * @summary Create Chat @@ -3248,6 +3366,33 @@ export const ChatApiFp = function(configuration?: Configuration) { const localVarOperationServerBasePath = operationServerMap['ChatApi.apiV1ChatsIdDelete']?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, + /** + * 将返回一个实体 + * @summary 显示一个对话的数据 + * @param {number} id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiV1ChatsIdGet(id: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1ChatsIdGet(id, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['ChatApi.apiV1ChatsIdGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * 可以重新设置对话的一些信息 + * @summary 更新对话 + * @param {number} id + * @param {SchemaChatUpdateRequest} schemaChatUpdateRequest ChatUpdateRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiV1ChatsIdPut(id: number, schemaChatUpdateRequest: SchemaChatUpdateRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1ChatsIdPut(id, schemaChatUpdateRequest, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['ChatApi.apiV1ChatsIdPut']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, /** * get string by ID * @summary Create Chat @@ -3302,6 +3447,27 @@ export const ChatApiFactory = function (configuration?: Configuration, basePath? apiV1ChatsIdDelete(id: number, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.apiV1ChatsIdDelete(id, options).then((request) => request(axios, basePath)); }, + /** + * 将返回一个实体 + * @summary 显示一个对话的数据 + * @param {number} id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ChatsIdGet(id: number, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.apiV1ChatsIdGet(id, options).then((request) => request(axios, basePath)); + }, + /** + * 可以重新设置对话的一些信息 + * @summary 更新对话 + * @param {number} id + * @param {SchemaChatUpdateRequest} schemaChatUpdateRequest ChatUpdateRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ChatsIdPut(id: number, schemaChatUpdateRequest: SchemaChatUpdateRequest, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.apiV1ChatsIdPut(id, schemaChatUpdateRequest, options).then((request) => request(axios, basePath)); + }, /** * get string by ID * @summary Create Chat @@ -3359,6 +3525,31 @@ export class ChatApi extends BaseAPI { return ChatApiFp(this.configuration).apiV1ChatsIdDelete(id, options).then((request) => request(this.axios, this.basePath)); } + /** + * 将返回一个实体 + * @summary 显示一个对话的数据 + * @param {number} id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ChatApi + */ + public apiV1ChatsIdGet(id: number, options?: RawAxiosRequestConfig) { + return ChatApiFp(this.configuration).apiV1ChatsIdGet(id, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * 可以重新设置对话的一些信息 + * @summary 更新对话 + * @param {number} id + * @param {SchemaChatUpdateRequest} schemaChatUpdateRequest ChatUpdateRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ChatApi + */ + public apiV1ChatsIdPut(id: number, schemaChatUpdateRequest: SchemaChatUpdateRequest, options?: RawAxiosRequestConfig) { + return ChatApiFp(this.configuration).apiV1ChatsIdPut(id, schemaChatUpdateRequest, options).then((request) => request(this.axios, this.basePath)); + } + /** * get string by ID * @summary Create Chat @@ -4639,6 +4830,49 @@ export const LibrariesApiAxiosParamCreator = function (configuration?: Configura options: localVarRequestOptions, }; }, + /** + * + * @summary 创建文档 + * @param {number} id + * @param {SchemaDocumentCreateRequest} schemaDocumentCreateRequest schema.DocumentCreateRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1LibrariesIdDocumentsPost: async (id: number, schemaDocumentCreateRequest: SchemaDocumentCreateRequest, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('apiV1LibrariesIdDocumentsPost', 'id', id) + // verify required parameter 'schemaDocumentCreateRequest' is not null or undefined + assertParamExists('apiV1LibrariesIdDocumentsPost', 'schemaDocumentCreateRequest', schemaDocumentCreateRequest) + const localVarPath = `/api/v1/libraries/{id}/documents` + .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) + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(schemaDocumentCreateRequest, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, /** * * @summary 获取一个资料库 @@ -4820,6 +5054,20 @@ export const LibrariesApiFp = function(configuration?: Configuration) { const localVarOperationServerBasePath = operationServerMap['LibrariesApi.apiV1LibrariesIdDocumentsGet']?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, + /** + * + * @summary 创建文档 + * @param {number} id + * @param {SchemaDocumentCreateRequest} schemaDocumentCreateRequest schema.DocumentCreateRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiV1LibrariesIdDocumentsPost(id: number, schemaDocumentCreateRequest: SchemaDocumentCreateRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1LibrariesIdDocumentsPost(id, schemaDocumentCreateRequest, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['LibrariesApi.apiV1LibrariesIdDocumentsPost']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, /** * * @summary 获取一个资料库 @@ -4910,6 +5158,17 @@ export const LibrariesApiFactory = function (configuration?: Configuration, base apiV1LibrariesIdDocumentsGet(id: number, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.apiV1LibrariesIdDocumentsGet(id, options).then((request) => request(axios, basePath)); }, + /** + * + * @summary 创建文档 + * @param {number} id + * @param {SchemaDocumentCreateRequest} schemaDocumentCreateRequest schema.DocumentCreateRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1LibrariesIdDocumentsPost(id: number, schemaDocumentCreateRequest: SchemaDocumentCreateRequest, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.apiV1LibrariesIdDocumentsPost(id, schemaDocumentCreateRequest, options).then((request) => request(axios, basePath)); + }, /** * * @summary 获取一个资料库 @@ -4999,6 +5258,19 @@ export class LibrariesApi extends BaseAPI { return LibrariesApiFp(this.configuration).apiV1LibrariesIdDocumentsGet(id, options).then((request) => request(this.axios, this.basePath)); } + /** + * + * @summary 创建文档 + * @param {number} id + * @param {SchemaDocumentCreateRequest} schemaDocumentCreateRequest schema.DocumentCreateRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof LibrariesApi + */ + public apiV1LibrariesIdDocumentsPost(id: number, schemaDocumentCreateRequest: SchemaDocumentCreateRequest, options?: RawAxiosRequestConfig) { + return LibrariesApiFp(this.configuration).apiV1LibrariesIdDocumentsPost(id, schemaDocumentCreateRequest, options).then((request) => request(this.axios, this.basePath)); + } + /** * * @summary 获取一个资料库 diff --git a/src/components.d.ts b/src/components.d.ts index 38bad60..2b42f87 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -11,6 +11,7 @@ declare module 'vue' { Assistants: typeof import('./components/assistants/index.vue')['default'] Chat: typeof import('./components/chat/chat.vue')['default'] ChatMenu: typeof import('./components/ChatMenu.vue')['default'] + ChatSettings: typeof import('./components/ChatSettings.vue')['default'] LeftSettings: typeof import('./components/LeftSettings.vue')['default'] Menu: typeof import('./components/Menu.vue')['default'] MessageList: typeof import('./components/chat/MessageList.vue')['default'] diff --git a/src/components/ChatSettings.vue b/src/components/ChatSettings.vue new file mode 100644 index 0000000..99b31cd --- /dev/null +++ b/src/components/ChatSettings.vue @@ -0,0 +1,165 @@ + + + diff --git a/src/components/LeftSettings.vue b/src/components/LeftSettings.vue index acc9aa1..68bae3b 100644 --- a/src/components/LeftSettings.vue +++ b/src/components/LeftSettings.vue @@ -1,46 +1,7 @@