diff --git a/.gitignore b/.gitignore index 11f5d71..149b576 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,4 @@ -.DS_Store +wwwroot/*.js node_modules -/dist - -# local env files -.env.local -.env.*.local - -# Log files -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# Editor directories and files -.idea -.vscode -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? +typings +dist diff --git a/api/swagger.yaml b/api/swagger.yaml new file mode 100644 index 0000000..73589c2 --- /dev/null +++ b/api/swagger.yaml @@ -0,0 +1,749 @@ +definitions: + rag-new_internal_entity.Assistant: + properties: + created_at: + type: string + description: + type: string + id: + type: integer + name: + type: string + prompt: + type: string + updated_at: + type: string + user_id: + type: integer + type: object + rag-new_internal_entity.AssistantTool: + properties: + assistant_id: + type: integer + created_at: + type: string + id: + type: integer + tool_id: + type: integer + updated_at: + type: string + type: object + rag-new_internal_entity.Chat: + properties: + assistant_id: + type: integer + created_at: + type: string + id: + type: integer + name: + type: string + updated_at: + type: string + user_id: + type: integer + type: object + rag-new_internal_entity.ChatMessage: + properties: + assistant_id: + type: integer + content: + type: string + created_at: + type: string + id: + type: integer + input_tokens: + type: integer + output_tokens: + type: integer + role: + type: string + total_tokens: + type: integer + updated_at: + type: string + type: object + rag-new_internal_entity.Tool: + properties: + api_key: + type: string + created_at: + type: string + data: + $ref: '#/definitions/rag-new_internal_schema.ToolDiscoveryOutput' + description: + type: string + discovery_url: + type: string + id: + type: integer + name: + type: string + updated_at: + type: string + user_id: + type: integer + type: object + rag-new_internal_schema.AssistantCreateRequest: + properties: + description: + maxLength: 255 + type: string + name: + maxLength: 255 + type: string + prompt: + type: string + required: + - description + - name + type: object + rag-new_internal_schema.ChatCreateRequest: + properties: + assistant_id: + type: integer + name: + maxLength: 255 + type: string + required: + - assistant_id + - name + type: object + rag-new_internal_schema.ChatMessageAddRequest: + properties: + message: + maxLength: 255 + type: string + required: + - message + type: object + rag-new_internal_schema.ChatMessageResponse: + properties: + stream_id: + type: string + type: object + rag-new_internal_schema.CurrentUserResponse: + properties: + ip: + type: string + userEmail: + type: string + userId: + type: integer + valid: + type: boolean + type: object + rag-new_internal_schema.ResponseBody: + properties: + data: {} + error: + type: string + message: + type: string + success: + type: boolean + type: object + rag-new_internal_schema.ToolCreateRequest: + properties: + api_key: + maxLength: 255 + type: string + description: + maxLength: 255 + type: string + name: + maxLength: 255 + type: string + url: + maxLength: 255 + type: string + required: + - description + - name + - url + type: object + rag-new_internal_schema.ToolDiscoveryOutput: + properties: + callback_url: + type: string + description: + type: string + function: + items: + $ref: '#/definitions/rag-new_internal_schema.ToolDiscoveryOutputFunctions' + type: array + homepage_url: + type: string + name: + type: string + type: object + rag-new_internal_schema.ToolDiscoveryOutputFunction: + properties: + description: + type: string + name: + type: string + parameters: {} + required: + items: + type: string + type: array + type: object + rag-new_internal_schema.ToolDiscoveryOutputFunctions: + properties: + function: + items: + $ref: '#/definitions/rag-new_internal_schema.ToolDiscoveryOutputFunction' + type: array + type: + type: string + type: object +info: + contact: {} + title: Leaflow Amber + version: "1.0" +paths: + /api/v1/assistants: + get: + consumes: + - application/json + description: get string by ID + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + - properties: + data: + items: + $ref: '#/definitions/rag-new_internal_entity.Assistant' + type: array + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + summary: 获取 Assistant 列表 + tags: + - assistant + post: + consumes: + - application/json + description: get string by ID + parameters: + - description: Assistant + in: body + name: assistant + required: true + schema: + $ref: '#/definitions/rag-new_internal_schema.AssistantCreateRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + - properties: + data: + $ref: '#/definitions/rag-new_internal_entity.Assistant' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + summary: 创建 Assistant + tags: + - assistant + /api/v1/assistants/{id}/tools: + get: + consumes: + - application/json + description: get string by ID + parameters: + - description: Assistant ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + - properties: + data: + items: + $ref: '#/definitions/rag-new_internal_entity.AssistantTool' + type: array + type: object + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + summary: 获取 Assistant 所绑定的 Tool + tags: + - assistant + /api/v1/assistants/{id}/tools/{tool_id}: + delete: + consumes: + - application/json + description: get string by ID + parameters: + - description: Assistant ID + in: path + name: id + required: true + type: integer + - description: Tool ID + in: path + name: tool_id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + - properties: + data: + $ref: '#/definitions/rag-new_internal_entity.AssistantTool' + type: object + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + summary: 解绑 Tool + tags: + - assistant + post: + consumes: + - application/json + description: get string by ID + parameters: + - description: Assistant ID + in: path + name: id + required: true + type: integer + - description: Tool ID + in: path + name: tool_id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + - properties: + data: + $ref: '#/definitions/rag-new_internal_entity.AssistantTool' + type: object + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + summary: 绑定 Tool + tags: + - assistant + /api/v1/chats: + get: + consumes: + - application/json + description: get string by ID + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + - properties: + data: + items: + $ref: '#/definitions/rag-new_internal_entity.Chat' + type: array + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + summary: 获取所有 Chat + tags: + - chat + post: + consumes: + - application/json + description: get string by ID + parameters: + - description: Chat + in: body + name: chat + required: true + schema: + $ref: '#/definitions/rag-new_internal_schema.ChatCreateRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + - properties: + data: + $ref: '#/definitions/rag-new_internal_entity.Chat' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + summary: Create Chat + tags: + - chat + /api/v1/chats/{id}: + delete: + consumes: + - application/json + description: get string by ID + parameters: + - description: Chat ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + "400": + description: Bad Request + schema: + $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + "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' + summary: Delete Chat + tags: + - chat + /api/v1/chats/{id}/messages: + get: + consumes: + - application/json + description: get string by ID + parameters: + - description: Chat ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + - properties: + data: + items: + $ref: '#/definitions/rag-new_internal_entity.ChatMessage' + type: array + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + "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' + summary: 查看聊天记录 + tags: + - chat_message + post: + consumes: + - application/json + description: get string by ID + parameters: + - description: Chat ID + in: path + name: id + required: true + type: integer + - description: Message + in: body + name: message + required: true + schema: + $ref: '#/definitions/rag-new_internal_schema.ChatMessageAddRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + - properties: + data: + $ref: '#/definitions/rag-new_internal_schema.ChatMessageResponse' + type: object + "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: + allOf: + - $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + - properties: + data: + $ref: '#/definitions/rag-new_internal_schema.ChatMessageResponse' + type: object + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + summary: 添加聊天记录 + tags: + - chat_message + /api/v1/ping: + get: + consumes: + - application/json + description: get string by ID + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + - properties: + data: + $ref: '#/definitions/rag-new_internal_schema.CurrentUserResponse' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + summary: Greet + tags: + - ping + /api/v1/stream/{stream_id}: + get: + consumes: + - application/json + description: get string by ID + parameters: + - description: Chat ID + in: path + name: id + required: true + type: integer + - description: Chat stream id + in: path + name: stream_id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + - properties: + data: + $ref: '#/definitions/rag-new_internal_schema.ChatMessageResponse' + type: object + "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: + allOf: + - $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + - properties: + data: + $ref: '#/definitions/rag-new_internal_schema.ChatMessageResponse' + type: object + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + security: + - none: [] + summary: 流式传输聊天内容 + tags: + - chat_message + /api/v1/tools: + get: + consumes: + - application/json + description: List tools + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + - properties: + data: + $ref: '#/definitions/rag-new_internal_schema.CurrentUserResponse' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + summary: List Tool + tags: + - tool + post: + consumes: + - application/json + description: Create tool + parameters: + - description: Tool + in: body + name: tool + required: true + schema: + $ref: '#/definitions/rag-new_internal_schema.ToolCreateRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + - properties: + data: + items: + $ref: '#/definitions/rag-new_internal_entity.Tool' + type: array + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + summary: Create Tool + tags: + - tool + /api/v1/tools/{id}: + delete: + consumes: + - application/json + description: DeleteTool + parameters: + - description: Tool ID + in: path + name: id + required: true + type: string + 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' + summary: DeleteTool + tags: + - tool + get: + consumes: + - application/json + description: Get tool + parameters: + - description: Tool ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + - properties: + data: + $ref: '#/definitions/rag-new_internal_entity.Tool' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + "404": + description: Not Found + schema: + $ref: '#/definitions/rag-new_internal_schema.ResponseBody' + summary: Get Tool + tags: + - tool +securityDefinitions: + ApiKeyAuth: + in: header + name: Authorization + type: apiKey +swagger: "2.0" diff --git a/openapitools.json b/openapitools.json new file mode 100644 index 0000000..f227cf2 --- /dev/null +++ b/openapitools.json @@ -0,0 +1,7 @@ +{ + "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json", + "spaces": 2, + "generator-cli": { + "version": "7.7.0" + } +} diff --git a/package.json b/package.json index 62cf0e7..f2a6f72 100644 --- a/package.json +++ b/package.json @@ -5,13 +5,15 @@ "dev": "vite", "build": "vue-tsc --noEmit && vite build", "preview": "vite preview", - "lint": "eslint . --fix --ignore-path .gitignore" + "lint": "eslint . --fix --ignore-path .gitignore", + "gen": "openapi-generator-cli generate -i ./api/swagger.yaml -g typescript-axios -o ./src/api" }, "dependencies": { "@mdi/font": "7.4.47", "axios": "^1.7.2", "core-js": "^3.37.1", "eslint-plugin-prettier": "^5.2.1", + "pinia-plugin-persistedstate": "^3.2.1", "roboto-fontface": "*", "vue": "^3.4.31", "vuetify": "^3.6.11" diff --git a/src/api/.gitignore b/src/api/.gitignore new file mode 100644 index 0000000..149b576 --- /dev/null +++ b/src/api/.gitignore @@ -0,0 +1,4 @@ +wwwroot/*.js +node_modules +typings +dist diff --git a/src/api/.npmignore b/src/api/.npmignore new file mode 100644 index 0000000..999d88d --- /dev/null +++ b/src/api/.npmignore @@ -0,0 +1 @@ +# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm \ No newline at end of file diff --git a/src/api/.openapi-generator-ignore b/src/api/.openapi-generator-ignore new file mode 100644 index 0000000..7484ee5 --- /dev/null +++ b/src/api/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/src/api/.openapi-generator/FILES b/src/api/.openapi-generator/FILES new file mode 100644 index 0000000..a80cd4f --- /dev/null +++ b/src/api/.openapi-generator/FILES @@ -0,0 +1,8 @@ +.gitignore +.npmignore +api.ts +base.ts +common.ts +configuration.ts +git_push.sh +index.ts diff --git a/src/api/.openapi-generator/VERSION b/src/api/.openapi-generator/VERSION new file mode 100644 index 0000000..1985849 --- /dev/null +++ b/src/api/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.7.0 diff --git a/src/api/api.ts b/src/api/api.ts new file mode 100644 index 0000000..8c0cd42 --- /dev/null +++ b/src/api/api.ts @@ -0,0 +1,2175 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Leaflow Amber + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import type { Configuration } from './configuration'; +import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios'; +import globalAxios from 'axios'; +// Some imports not used depending on template conditions +// @ts-ignore +import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common'; +import type { RequestArgs } from './base'; +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError, operationServerMap } from './base'; + +/** + * + * @export + * @interface ApiV1AssistantsGet200Response + */ +export interface ApiV1AssistantsGet200Response { + /** + * + * @type {Array} + * @memberof ApiV1AssistantsGet200Response + */ + 'data'?: Array; + /** + * + * @type {string} + * @memberof ApiV1AssistantsGet200Response + */ + 'error'?: string; + /** + * + * @type {string} + * @memberof ApiV1AssistantsGet200Response + */ + 'message'?: string; + /** + * + * @type {boolean} + * @memberof ApiV1AssistantsGet200Response + */ + 'success'?: boolean; +} +/** + * + * @export + * @interface ApiV1AssistantsIdToolsGet200Response + */ +export interface ApiV1AssistantsIdToolsGet200Response { + /** + * + * @type {Array} + * @memberof ApiV1AssistantsIdToolsGet200Response + */ + 'data'?: Array; + /** + * + * @type {string} + * @memberof ApiV1AssistantsIdToolsGet200Response + */ + 'error'?: string; + /** + * + * @type {string} + * @memberof ApiV1AssistantsIdToolsGet200Response + */ + 'message'?: string; + /** + * + * @type {boolean} + * @memberof ApiV1AssistantsIdToolsGet200Response + */ + 'success'?: boolean; +} +/** + * + * @export + * @interface ApiV1AssistantsIdToolsToolIdPost200Response + */ +export interface ApiV1AssistantsIdToolsToolIdPost200Response { + /** + * + * @type {RagNewInternalEntityAssistantTool} + * @memberof ApiV1AssistantsIdToolsToolIdPost200Response + */ + 'data'?: RagNewInternalEntityAssistantTool; + /** + * + * @type {string} + * @memberof ApiV1AssistantsIdToolsToolIdPost200Response + */ + 'error'?: string; + /** + * + * @type {string} + * @memberof ApiV1AssistantsIdToolsToolIdPost200Response + */ + 'message'?: string; + /** + * + * @type {boolean} + * @memberof ApiV1AssistantsIdToolsToolIdPost200Response + */ + 'success'?: boolean; +} +/** + * + * @export + * @interface ApiV1AssistantsPost200Response + */ +export interface ApiV1AssistantsPost200Response { + /** + * + * @type {RagNewInternalEntityAssistant} + * @memberof ApiV1AssistantsPost200Response + */ + 'data'?: RagNewInternalEntityAssistant; + /** + * + * @type {string} + * @memberof ApiV1AssistantsPost200Response + */ + 'error'?: string; + /** + * + * @type {string} + * @memberof ApiV1AssistantsPost200Response + */ + 'message'?: string; + /** + * + * @type {boolean} + * @memberof ApiV1AssistantsPost200Response + */ + 'success'?: boolean; +} +/** + * + * @export + * @interface ApiV1ChatsGet200Response + */ +export interface ApiV1ChatsGet200Response { + /** + * + * @type {Array} + * @memberof ApiV1ChatsGet200Response + */ + 'data'?: Array; + /** + * + * @type {string} + * @memberof ApiV1ChatsGet200Response + */ + 'error'?: string; + /** + * + * @type {string} + * @memberof ApiV1ChatsGet200Response + */ + 'message'?: string; + /** + * + * @type {boolean} + * @memberof ApiV1ChatsGet200Response + */ + 'success'?: boolean; +} +/** + * + * @export + * @interface ApiV1ChatsIdMessagesGet200Response + */ +export interface ApiV1ChatsIdMessagesGet200Response { + /** + * + * @type {Array} + * @memberof ApiV1ChatsIdMessagesGet200Response + */ + 'data'?: Array; + /** + * + * @type {string} + * @memberof ApiV1ChatsIdMessagesGet200Response + */ + 'error'?: string; + /** + * + * @type {string} + * @memberof ApiV1ChatsIdMessagesGet200Response + */ + 'message'?: string; + /** + * + * @type {boolean} + * @memberof ApiV1ChatsIdMessagesGet200Response + */ + 'success'?: boolean; +} +/** + * + * @export + * @interface ApiV1ChatsIdMessagesPost200Response + */ +export interface ApiV1ChatsIdMessagesPost200Response { + /** + * + * @type {RagNewInternalSchemaChatMessageResponse} + * @memberof ApiV1ChatsIdMessagesPost200Response + */ + 'data'?: RagNewInternalSchemaChatMessageResponse; + /** + * + * @type {string} + * @memberof ApiV1ChatsIdMessagesPost200Response + */ + 'error'?: string; + /** + * + * @type {string} + * @memberof ApiV1ChatsIdMessagesPost200Response + */ + 'message'?: string; + /** + * + * @type {boolean} + * @memberof ApiV1ChatsIdMessagesPost200Response + */ + 'success'?: boolean; +} +/** + * + * @export + * @interface ApiV1ChatsPost200Response + */ +export interface ApiV1ChatsPost200Response { + /** + * + * @type {RagNewInternalEntityChat} + * @memberof ApiV1ChatsPost200Response + */ + 'data'?: RagNewInternalEntityChat; + /** + * + * @type {string} + * @memberof ApiV1ChatsPost200Response + */ + 'error'?: string; + /** + * + * @type {string} + * @memberof ApiV1ChatsPost200Response + */ + 'message'?: string; + /** + * + * @type {boolean} + * @memberof ApiV1ChatsPost200Response + */ + 'success'?: boolean; +} +/** + * + * @export + * @interface ApiV1PingGet200Response + */ +export interface ApiV1PingGet200Response { + /** + * + * @type {RagNewInternalSchemaCurrentUserResponse} + * @memberof ApiV1PingGet200Response + */ + 'data'?: RagNewInternalSchemaCurrentUserResponse; + /** + * + * @type {string} + * @memberof ApiV1PingGet200Response + */ + 'error'?: string; + /** + * + * @type {string} + * @memberof ApiV1PingGet200Response + */ + 'message'?: string; + /** + * + * @type {boolean} + * @memberof ApiV1PingGet200Response + */ + 'success'?: boolean; +} +/** + * + * @export + * @interface ApiV1ToolsIdGet200Response + */ +export interface ApiV1ToolsIdGet200Response { + /** + * + * @type {RagNewInternalEntityTool} + * @memberof ApiV1ToolsIdGet200Response + */ + 'data'?: RagNewInternalEntityTool; + /** + * + * @type {string} + * @memberof ApiV1ToolsIdGet200Response + */ + 'error'?: string; + /** + * + * @type {string} + * @memberof ApiV1ToolsIdGet200Response + */ + 'message'?: string; + /** + * + * @type {boolean} + * @memberof ApiV1ToolsIdGet200Response + */ + 'success'?: boolean; +} +/** + * + * @export + * @interface ApiV1ToolsPost200Response + */ +export interface ApiV1ToolsPost200Response { + /** + * + * @type {Array} + * @memberof ApiV1ToolsPost200Response + */ + 'data'?: Array; + /** + * + * @type {string} + * @memberof ApiV1ToolsPost200Response + */ + 'error'?: string; + /** + * + * @type {string} + * @memberof ApiV1ToolsPost200Response + */ + 'message'?: string; + /** + * + * @type {boolean} + * @memberof ApiV1ToolsPost200Response + */ + 'success'?: boolean; +} +/** + * + * @export + * @interface RagNewInternalEntityAssistant + */ +export interface RagNewInternalEntityAssistant { + /** + * + * @type {string} + * @memberof RagNewInternalEntityAssistant + */ + 'created_at'?: string; + /** + * + * @type {string} + * @memberof RagNewInternalEntityAssistant + */ + 'description'?: string; + /** + * + * @type {number} + * @memberof RagNewInternalEntityAssistant + */ + 'id'?: number; + /** + * + * @type {string} + * @memberof RagNewInternalEntityAssistant + */ + 'name'?: string; + /** + * + * @type {string} + * @memberof RagNewInternalEntityAssistant + */ + 'prompt'?: string; + /** + * + * @type {string} + * @memberof RagNewInternalEntityAssistant + */ + 'updated_at'?: string; + /** + * + * @type {number} + * @memberof RagNewInternalEntityAssistant + */ + 'user_id'?: number; +} +/** + * + * @export + * @interface RagNewInternalEntityAssistantTool + */ +export interface RagNewInternalEntityAssistantTool { + /** + * + * @type {number} + * @memberof RagNewInternalEntityAssistantTool + */ + 'assistant_id'?: number; + /** + * + * @type {string} + * @memberof RagNewInternalEntityAssistantTool + */ + 'created_at'?: string; + /** + * + * @type {number} + * @memberof RagNewInternalEntityAssistantTool + */ + 'id'?: number; + /** + * + * @type {number} + * @memberof RagNewInternalEntityAssistantTool + */ + 'tool_id'?: number; + /** + * + * @type {string} + * @memberof RagNewInternalEntityAssistantTool + */ + 'updated_at'?: string; +} +/** + * + * @export + * @interface RagNewInternalEntityChat + */ +export interface RagNewInternalEntityChat { + /** + * + * @type {number} + * @memberof RagNewInternalEntityChat + */ + 'assistant_id'?: number; + /** + * + * @type {string} + * @memberof RagNewInternalEntityChat + */ + 'created_at'?: string; + /** + * + * @type {number} + * @memberof RagNewInternalEntityChat + */ + 'id'?: number; + /** + * + * @type {string} + * @memberof RagNewInternalEntityChat + */ + 'name'?: string; + /** + * + * @type {string} + * @memberof RagNewInternalEntityChat + */ + 'updated_at'?: string; + /** + * + * @type {number} + * @memberof RagNewInternalEntityChat + */ + 'user_id'?: number; +} +/** + * + * @export + * @interface RagNewInternalEntityChatMessage + */ +export interface RagNewInternalEntityChatMessage { + /** + * + * @type {number} + * @memberof RagNewInternalEntityChatMessage + */ + 'assistant_id'?: number; + /** + * + * @type {string} + * @memberof RagNewInternalEntityChatMessage + */ + 'content'?: string; + /** + * + * @type {string} + * @memberof RagNewInternalEntityChatMessage + */ + 'created_at'?: string; + /** + * + * @type {number} + * @memberof RagNewInternalEntityChatMessage + */ + 'id'?: number; + /** + * + * @type {number} + * @memberof RagNewInternalEntityChatMessage + */ + 'input_tokens'?: number; + /** + * + * @type {number} + * @memberof RagNewInternalEntityChatMessage + */ + 'output_tokens'?: number; + /** + * + * @type {string} + * @memberof RagNewInternalEntityChatMessage + */ + 'role'?: string; + /** + * + * @type {number} + * @memberof RagNewInternalEntityChatMessage + */ + 'total_tokens'?: number; + /** + * + * @type {string} + * @memberof RagNewInternalEntityChatMessage + */ + 'updated_at'?: string; +} +/** + * + * @export + * @interface RagNewInternalEntityTool + */ +export interface RagNewInternalEntityTool { + /** + * + * @type {string} + * @memberof RagNewInternalEntityTool + */ + 'api_key'?: string; + /** + * + * @type {string} + * @memberof RagNewInternalEntityTool + */ + 'created_at'?: string; + /** + * + * @type {RagNewInternalSchemaToolDiscoveryOutput} + * @memberof RagNewInternalEntityTool + */ + 'data'?: RagNewInternalSchemaToolDiscoveryOutput; + /** + * + * @type {string} + * @memberof RagNewInternalEntityTool + */ + 'description'?: string; + /** + * + * @type {string} + * @memberof RagNewInternalEntityTool + */ + 'discovery_url'?: string; + /** + * + * @type {number} + * @memberof RagNewInternalEntityTool + */ + 'id'?: number; + /** + * + * @type {string} + * @memberof RagNewInternalEntityTool + */ + 'name'?: string; + /** + * + * @type {string} + * @memberof RagNewInternalEntityTool + */ + 'updated_at'?: string; + /** + * + * @type {number} + * @memberof RagNewInternalEntityTool + */ + 'user_id'?: number; +} +/** + * + * @export + * @interface RagNewInternalSchemaAssistantCreateRequest + */ +export interface RagNewInternalSchemaAssistantCreateRequest { + /** + * + * @type {string} + * @memberof RagNewInternalSchemaAssistantCreateRequest + */ + 'description': string; + /** + * + * @type {string} + * @memberof RagNewInternalSchemaAssistantCreateRequest + */ + 'name': string; + /** + * + * @type {string} + * @memberof RagNewInternalSchemaAssistantCreateRequest + */ + 'prompt'?: string; +} +/** + * + * @export + * @interface RagNewInternalSchemaChatCreateRequest + */ +export interface RagNewInternalSchemaChatCreateRequest { + /** + * + * @type {number} + * @memberof RagNewInternalSchemaChatCreateRequest + */ + 'assistant_id': number; + /** + * + * @type {string} + * @memberof RagNewInternalSchemaChatCreateRequest + */ + 'name': string; +} +/** + * + * @export + * @interface RagNewInternalSchemaChatMessageAddRequest + */ +export interface RagNewInternalSchemaChatMessageAddRequest { + /** + * + * @type {string} + * @memberof RagNewInternalSchemaChatMessageAddRequest + */ + 'message': string; +} +/** + * + * @export + * @interface RagNewInternalSchemaChatMessageResponse + */ +export interface RagNewInternalSchemaChatMessageResponse { + /** + * + * @type {string} + * @memberof RagNewInternalSchemaChatMessageResponse + */ + 'stream_id'?: string; +} +/** + * + * @export + * @interface RagNewInternalSchemaCurrentUserResponse + */ +export interface RagNewInternalSchemaCurrentUserResponse { + /** + * + * @type {string} + * @memberof RagNewInternalSchemaCurrentUserResponse + */ + 'ip'?: string; + /** + * + * @type {string} + * @memberof RagNewInternalSchemaCurrentUserResponse + */ + 'userEmail'?: string; + /** + * + * @type {number} + * @memberof RagNewInternalSchemaCurrentUserResponse + */ + 'userId'?: number; + /** + * + * @type {boolean} + * @memberof RagNewInternalSchemaCurrentUserResponse + */ + 'valid'?: boolean; +} +/** + * + * @export + * @interface RagNewInternalSchemaResponseBody + */ +export interface RagNewInternalSchemaResponseBody { + /** + * + * @type {object} + * @memberof RagNewInternalSchemaResponseBody + */ + 'data'?: object; + /** + * + * @type {string} + * @memberof RagNewInternalSchemaResponseBody + */ + 'error'?: string; + /** + * + * @type {string} + * @memberof RagNewInternalSchemaResponseBody + */ + 'message'?: string; + /** + * + * @type {boolean} + * @memberof RagNewInternalSchemaResponseBody + */ + 'success'?: boolean; +} +/** + * + * @export + * @interface RagNewInternalSchemaToolCreateRequest + */ +export interface RagNewInternalSchemaToolCreateRequest { + /** + * + * @type {string} + * @memberof RagNewInternalSchemaToolCreateRequest + */ + 'api_key'?: string; + /** + * + * @type {string} + * @memberof RagNewInternalSchemaToolCreateRequest + */ + 'description': string; + /** + * + * @type {string} + * @memberof RagNewInternalSchemaToolCreateRequest + */ + 'name': string; + /** + * + * @type {string} + * @memberof RagNewInternalSchemaToolCreateRequest + */ + 'url': string; +} +/** + * + * @export + * @interface RagNewInternalSchemaToolDiscoveryOutput + */ +export interface RagNewInternalSchemaToolDiscoveryOutput { + /** + * + * @type {string} + * @memberof RagNewInternalSchemaToolDiscoveryOutput + */ + 'callback_url'?: string; + /** + * + * @type {string} + * @memberof RagNewInternalSchemaToolDiscoveryOutput + */ + 'description'?: string; + /** + * + * @type {Array} + * @memberof RagNewInternalSchemaToolDiscoveryOutput + */ + 'function'?: Array; + /** + * + * @type {string} + * @memberof RagNewInternalSchemaToolDiscoveryOutput + */ + 'homepage_url'?: string; + /** + * + * @type {string} + * @memberof RagNewInternalSchemaToolDiscoveryOutput + */ + 'name'?: string; +} +/** + * + * @export + * @interface RagNewInternalSchemaToolDiscoveryOutputFunction + */ +export interface RagNewInternalSchemaToolDiscoveryOutputFunction { + /** + * + * @type {string} + * @memberof RagNewInternalSchemaToolDiscoveryOutputFunction + */ + 'description'?: string; + /** + * + * @type {string} + * @memberof RagNewInternalSchemaToolDiscoveryOutputFunction + */ + 'name'?: string; + /** + * + * @type {object} + * @memberof RagNewInternalSchemaToolDiscoveryOutputFunction + */ + 'parameters'?: object; + /** + * + * @type {Array} + * @memberof RagNewInternalSchemaToolDiscoveryOutputFunction + */ + 'required'?: Array; +} +/** + * + * @export + * @interface RagNewInternalSchemaToolDiscoveryOutputFunctions + */ +export interface RagNewInternalSchemaToolDiscoveryOutputFunctions { + /** + * + * @type {Array} + * @memberof RagNewInternalSchemaToolDiscoveryOutputFunctions + */ + 'function'?: Array; + /** + * + * @type {string} + * @memberof RagNewInternalSchemaToolDiscoveryOutputFunctions + */ + 'type'?: string; +} + +/** + * AssistantApi - axios parameter creator + * @export + */ +export const AssistantApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * get string by ID + * @summary 获取 Assistant 列表 + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1AssistantsGet: async (options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/v1/assistants`; + // 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; + + + + 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 所绑定的 Tool + * @param {number} id Assistant ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1AssistantsIdToolsGet: async (id: number, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('apiV1AssistantsIdToolsGet', 'id', id) + const localVarPath = `/api/v1/assistants/{id}/tools` + .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; + + + + 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 解绑 Tool + * @param {number} id Assistant ID + * @param {number} toolId Tool ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1AssistantsIdToolsToolIdDelete: async (id: number, toolId: number, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('apiV1AssistantsIdToolsToolIdDelete', 'id', id) + // verify required parameter 'toolId' is not null or undefined + assertParamExists('apiV1AssistantsIdToolsToolIdDelete', 'toolId', toolId) + const localVarPath = `/api/v1/assistants/{id}/tools/{tool_id}` + .replace(`{${"id"}}`, encodeURIComponent(String(id))) + .replace(`{${"tool_id"}}`, encodeURIComponent(String(toolId))); + // 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; + + + + 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 绑定 Tool + * @param {number} id Assistant ID + * @param {number} toolId Tool ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1AssistantsIdToolsToolIdPost: async (id: number, toolId: number, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('apiV1AssistantsIdToolsToolIdPost', 'id', id) + // verify required parameter 'toolId' is not null or undefined + assertParamExists('apiV1AssistantsIdToolsToolIdPost', 'toolId', toolId) + const localVarPath = `/api/v1/assistants/{id}/tools/{tool_id}` + .replace(`{${"id"}}`, encodeURIComponent(String(id))) + .replace(`{${"tool_id"}}`, encodeURIComponent(String(toolId))); + // 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; + + + + 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 {RagNewInternalSchemaAssistantCreateRequest} assistant Assistant + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1AssistantsPost: async (assistant: RagNewInternalSchemaAssistantCreateRequest, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'assistant' is not null or undefined + assertParamExists('apiV1AssistantsPost', 'assistant', assistant) + const localVarPath = `/api/v1/assistants`; + // 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; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(assistant, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * AssistantApi - functional programming interface + * @export + */ +export const AssistantApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = AssistantApiAxiosParamCreator(configuration) + return { + /** + * get string by ID + * @summary 获取 Assistant 列表 + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiV1AssistantsGet(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1AssistantsGet(options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['AssistantApi.apiV1AssistantsGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * get string by ID + * @summary 获取 Assistant 所绑定的 Tool + * @param {number} id Assistant ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiV1AssistantsIdToolsGet(id: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1AssistantsIdToolsGet(id, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['AssistantApi.apiV1AssistantsIdToolsGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * get string by ID + * @summary 解绑 Tool + * @param {number} id Assistant ID + * @param {number} toolId Tool ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiV1AssistantsIdToolsToolIdDelete(id: number, toolId: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1AssistantsIdToolsToolIdDelete(id, toolId, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['AssistantApi.apiV1AssistantsIdToolsToolIdDelete']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * get string by ID + * @summary 绑定 Tool + * @param {number} id Assistant ID + * @param {number} toolId Tool ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiV1AssistantsIdToolsToolIdPost(id: number, toolId: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1AssistantsIdToolsToolIdPost(id, toolId, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['AssistantApi.apiV1AssistantsIdToolsToolIdPost']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * get string by ID + * @summary 创建 Assistant + * @param {RagNewInternalSchemaAssistantCreateRequest} assistant Assistant + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiV1AssistantsPost(assistant: RagNewInternalSchemaAssistantCreateRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1AssistantsPost(assistant, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['AssistantApi.apiV1AssistantsPost']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + } +}; + +/** + * AssistantApi - factory interface + * @export + */ +export const AssistantApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = AssistantApiFp(configuration) + return { + /** + * get string by ID + * @summary 获取 Assistant 列表 + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1AssistantsGet(options?: any): AxiosPromise { + return localVarFp.apiV1AssistantsGet(options).then((request) => request(axios, basePath)); + }, + /** + * get string by ID + * @summary 获取 Assistant 所绑定的 Tool + * @param {number} id Assistant ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1AssistantsIdToolsGet(id: number, options?: any): AxiosPromise { + return localVarFp.apiV1AssistantsIdToolsGet(id, options).then((request) => request(axios, basePath)); + }, + /** + * get string by ID + * @summary 解绑 Tool + * @param {number} id Assistant ID + * @param {number} toolId Tool ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1AssistantsIdToolsToolIdDelete(id: number, toolId: number, options?: any): AxiosPromise { + return localVarFp.apiV1AssistantsIdToolsToolIdDelete(id, toolId, options).then((request) => request(axios, basePath)); + }, + /** + * get string by ID + * @summary 绑定 Tool + * @param {number} id Assistant ID + * @param {number} toolId Tool ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1AssistantsIdToolsToolIdPost(id: number, toolId: number, options?: any): AxiosPromise { + return localVarFp.apiV1AssistantsIdToolsToolIdPost(id, toolId, options).then((request) => request(axios, basePath)); + }, + /** + * get string by ID + * @summary 创建 Assistant + * @param {RagNewInternalSchemaAssistantCreateRequest} assistant Assistant + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1AssistantsPost(assistant: RagNewInternalSchemaAssistantCreateRequest, options?: any): AxiosPromise { + return localVarFp.apiV1AssistantsPost(assistant, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * AssistantApi - object-oriented interface + * @export + * @class AssistantApi + * @extends {BaseAPI} + */ +export class AssistantApi extends BaseAPI { + /** + * get string by ID + * @summary 获取 Assistant 列表 + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof AssistantApi + */ + public apiV1AssistantsGet(options?: RawAxiosRequestConfig) { + return AssistantApiFp(this.configuration).apiV1AssistantsGet(options).then((request) => request(this.axios, this.basePath)); + } + + /** + * get string by ID + * @summary 获取 Assistant 所绑定的 Tool + * @param {number} id Assistant ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof AssistantApi + */ + public apiV1AssistantsIdToolsGet(id: number, options?: RawAxiosRequestConfig) { + return AssistantApiFp(this.configuration).apiV1AssistantsIdToolsGet(id, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * get string by ID + * @summary 解绑 Tool + * @param {number} id Assistant ID + * @param {number} toolId Tool ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof AssistantApi + */ + public apiV1AssistantsIdToolsToolIdDelete(id: number, toolId: number, options?: RawAxiosRequestConfig) { + return AssistantApiFp(this.configuration).apiV1AssistantsIdToolsToolIdDelete(id, toolId, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * get string by ID + * @summary 绑定 Tool + * @param {number} id Assistant ID + * @param {number} toolId Tool ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof AssistantApi + */ + public apiV1AssistantsIdToolsToolIdPost(id: number, toolId: number, options?: RawAxiosRequestConfig) { + return AssistantApiFp(this.configuration).apiV1AssistantsIdToolsToolIdPost(id, toolId, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * get string by ID + * @summary 创建 Assistant + * @param {RagNewInternalSchemaAssistantCreateRequest} assistant Assistant + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof AssistantApi + */ + public apiV1AssistantsPost(assistant: RagNewInternalSchemaAssistantCreateRequest, options?: RawAxiosRequestConfig) { + return AssistantApiFp(this.configuration).apiV1AssistantsPost(assistant, options).then((request) => request(this.axios, this.basePath)); + } +} + + + +/** + * ChatApi - axios parameter creator + * @export + */ +export const ChatApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * get string by ID + * @summary 获取所有 Chat + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ChatsGet: async (options: RawAxiosRequestConfig = {}): Promise => { + 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); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + 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 Delete Chat + * @param {number} id Chat ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ChatsIdDelete: async (id: number, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('apiV1ChatsIdDelete', '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: 'DELETE', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + 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 Create Chat + * @param {RagNewInternalSchemaChatCreateRequest} chat Chat + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ChatsPost: async (chat: RagNewInternalSchemaChatCreateRequest, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'chat' is not null or undefined + assertParamExists('apiV1ChatsPost', 'chat', chat) + 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); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(chat, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * ChatApi - functional programming interface + * @export + */ +export const ChatApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = ChatApiAxiosParamCreator(configuration) + return { + /** + * get string by ID + * @summary 获取所有 Chat + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiV1ChatsGet(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1ChatsGet(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); + }, + /** + * get string by ID + * @summary Delete Chat + * @param {number} id Chat ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiV1ChatsIdDelete(id: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1ChatsIdDelete(id, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['ChatApi.apiV1ChatsIdDelete']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * get string by ID + * @summary Create Chat + * @param {RagNewInternalSchemaChatCreateRequest} chat Chat + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiV1ChatsPost(chat: RagNewInternalSchemaChatCreateRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1ChatsPost(chat, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['ChatApi.apiV1ChatsPost']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + } +}; + +/** + * ChatApi - factory interface + * @export + */ +export const ChatApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = ChatApiFp(configuration) + return { + /** + * get string by ID + * @summary 获取所有 Chat + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ChatsGet(options?: any): AxiosPromise { + return localVarFp.apiV1ChatsGet(options).then((request) => request(axios, basePath)); + }, + /** + * get string by ID + * @summary Delete Chat + * @param {number} id Chat ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ChatsIdDelete(id: number, options?: any): AxiosPromise { + return localVarFp.apiV1ChatsIdDelete(id, options).then((request) => request(axios, basePath)); + }, + /** + * get string by ID + * @summary Create Chat + * @param {RagNewInternalSchemaChatCreateRequest} chat Chat + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ChatsPost(chat: RagNewInternalSchemaChatCreateRequest, options?: any): AxiosPromise { + return localVarFp.apiV1ChatsPost(chat, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * ChatApi - object-oriented interface + * @export + * @class ChatApi + * @extends {BaseAPI} + */ +export class ChatApi extends BaseAPI { + /** + * get string by ID + * @summary 获取所有 Chat + * @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)); + } + + /** + * get string by ID + * @summary Delete Chat + * @param {number} id Chat ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ChatApi + */ + public apiV1ChatsIdDelete(id: number, options?: RawAxiosRequestConfig) { + return ChatApiFp(this.configuration).apiV1ChatsIdDelete(id, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * get string by ID + * @summary Create Chat + * @param {RagNewInternalSchemaChatCreateRequest} chat Chat + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ChatApi + */ + public apiV1ChatsPost(chat: RagNewInternalSchemaChatCreateRequest, options?: RawAxiosRequestConfig) { + return ChatApiFp(this.configuration).apiV1ChatsPost(chat, options).then((request) => request(this.axios, this.basePath)); + } +} + + + +/** + * ChatMessageApi - axios parameter creator + * @export + */ +export const ChatMessageApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * get string by ID + * @summary 查看聊天记录 + * @param {number} id Chat ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ChatsIdMessagesGet: async (id: number, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('apiV1ChatsIdMessagesGet', 'id', id) + const localVarPath = `/api/v1/chats/{id}/messages` + .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; + + + + 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 添加聊天记录 + * @param {number} id Chat ID + * @param {RagNewInternalSchemaChatMessageAddRequest} message Message + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ChatsIdMessagesPost: async (id: number, message: RagNewInternalSchemaChatMessageAddRequest, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('apiV1ChatsIdMessagesPost', 'id', id) + // verify required parameter 'message' is not null or undefined + assertParamExists('apiV1ChatsIdMessagesPost', 'message', message) + const localVarPath = `/api/v1/chats/{id}/messages` + .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; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(message, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * get string by ID + * @summary 流式传输聊天内容 + * @param {number} id Chat ID + * @param {string} streamId Chat stream id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1StreamStreamIdGet: async (id: number, streamId: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('apiV1StreamStreamIdGet', 'id', id) + // verify required parameter 'streamId' is not null or undefined + assertParamExists('apiV1StreamStreamIdGet', 'streamId', streamId) + const localVarPath = `/api/v1/stream/{stream_id}` + .replace(`{${"id"}}`, encodeURIComponent(String(id))) + .replace(`{${"stream_id"}}`, encodeURIComponent(String(streamId))); + // 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; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * ChatMessageApi - functional programming interface + * @export + */ +export const ChatMessageApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = ChatMessageApiAxiosParamCreator(configuration) + return { + /** + * get string by ID + * @summary 查看聊天记录 + * @param {number} id Chat ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiV1ChatsIdMessagesGet(id: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1ChatsIdMessagesGet(id, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['ChatMessageApi.apiV1ChatsIdMessagesGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * get string by ID + * @summary 添加聊天记录 + * @param {number} id Chat ID + * @param {RagNewInternalSchemaChatMessageAddRequest} message Message + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiV1ChatsIdMessagesPost(id: number, message: RagNewInternalSchemaChatMessageAddRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1ChatsIdMessagesPost(id, message, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['ChatMessageApi.apiV1ChatsIdMessagesPost']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * get string by ID + * @summary 流式传输聊天内容 + * @param {number} id Chat ID + * @param {string} streamId Chat stream id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiV1StreamStreamIdGet(id: number, streamId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1StreamStreamIdGet(id, streamId, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['ChatMessageApi.apiV1StreamStreamIdGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + } +}; + +/** + * ChatMessageApi - factory interface + * @export + */ +export const ChatMessageApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = ChatMessageApiFp(configuration) + return { + /** + * get string by ID + * @summary 查看聊天记录 + * @param {number} id Chat ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ChatsIdMessagesGet(id: number, options?: any): AxiosPromise { + return localVarFp.apiV1ChatsIdMessagesGet(id, options).then((request) => request(axios, basePath)); + }, + /** + * get string by ID + * @summary 添加聊天记录 + * @param {number} id Chat ID + * @param {RagNewInternalSchemaChatMessageAddRequest} message Message + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ChatsIdMessagesPost(id: number, message: RagNewInternalSchemaChatMessageAddRequest, options?: any): AxiosPromise { + return localVarFp.apiV1ChatsIdMessagesPost(id, message, options).then((request) => request(axios, basePath)); + }, + /** + * get string by ID + * @summary 流式传输聊天内容 + * @param {number} id Chat ID + * @param {string} streamId Chat stream id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1StreamStreamIdGet(id: number, streamId: string, options?: any): AxiosPromise { + return localVarFp.apiV1StreamStreamIdGet(id, streamId, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * ChatMessageApi - object-oriented interface + * @export + * @class ChatMessageApi + * @extends {BaseAPI} + */ +export class ChatMessageApi extends BaseAPI { + /** + * get string by ID + * @summary 查看聊天记录 + * @param {number} id Chat ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ChatMessageApi + */ + public apiV1ChatsIdMessagesGet(id: number, options?: RawAxiosRequestConfig) { + return ChatMessageApiFp(this.configuration).apiV1ChatsIdMessagesGet(id, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * get string by ID + * @summary 添加聊天记录 + * @param {number} id Chat ID + * @param {RagNewInternalSchemaChatMessageAddRequest} message Message + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ChatMessageApi + */ + public apiV1ChatsIdMessagesPost(id: number, message: RagNewInternalSchemaChatMessageAddRequest, options?: RawAxiosRequestConfig) { + return ChatMessageApiFp(this.configuration).apiV1ChatsIdMessagesPost(id, message, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * get string by ID + * @summary 流式传输聊天内容 + * @param {number} id Chat ID + * @param {string} streamId Chat stream id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ChatMessageApi + */ + public apiV1StreamStreamIdGet(id: number, streamId: string, options?: RawAxiosRequestConfig) { + return ChatMessageApiFp(this.configuration).apiV1StreamStreamIdGet(id, streamId, options).then((request) => request(this.axios, this.basePath)); + } +} + + + +/** + * PingApi - axios parameter creator + * @export + */ +export const PingApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * get string by ID + * @summary Greet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1PingGet: async (options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/v1/ping`; + // 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; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * PingApi - functional programming interface + * @export + */ +export const PingApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = PingApiAxiosParamCreator(configuration) + return { + /** + * get string by ID + * @summary Greet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiV1PingGet(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1PingGet(options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['PingApi.apiV1PingGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + } +}; + +/** + * PingApi - factory interface + * @export + */ +export const PingApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = PingApiFp(configuration) + return { + /** + * get string by ID + * @summary Greet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1PingGet(options?: any): AxiosPromise { + return localVarFp.apiV1PingGet(options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * PingApi - object-oriented interface + * @export + * @class PingApi + * @extends {BaseAPI} + */ +export class PingApi extends BaseAPI { + /** + * get string by ID + * @summary Greet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PingApi + */ + public apiV1PingGet(options?: RawAxiosRequestConfig) { + return PingApiFp(this.configuration).apiV1PingGet(options).then((request) => request(this.axios, this.basePath)); + } +} + + + +/** + * ToolApi - axios parameter creator + * @export + */ +export const ToolApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * List tools + * @summary List Tool + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ToolsGet: async (options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/v1/tools`; + // 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; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * DeleteTool + * @summary DeleteTool + * @param {string} id Tool ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ToolsIdDelete: async (id: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('apiV1ToolsIdDelete', 'id', id) + const localVarPath = `/api/v1/tools/{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; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Get tool + * @summary Get Tool + * @param {string} id Tool ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ToolsIdGet: async (id: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('apiV1ToolsIdGet', 'id', id) + const localVarPath = `/api/v1/tools/{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; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Create tool + * @summary Create Tool + * @param {RagNewInternalSchemaToolCreateRequest} tool Tool + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ToolsPost: async (tool: RagNewInternalSchemaToolCreateRequest, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'tool' is not null or undefined + assertParamExists('apiV1ToolsPost', 'tool', tool) + const localVarPath = `/api/v1/tools`; + // 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; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(tool, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * ToolApi - functional programming interface + * @export + */ +export const ToolApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = ToolApiAxiosParamCreator(configuration) + return { + /** + * List tools + * @summary List Tool + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiV1ToolsGet(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1ToolsGet(options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['ToolApi.apiV1ToolsGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * DeleteTool + * @summary DeleteTool + * @param {string} id Tool ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiV1ToolsIdDelete(id: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1ToolsIdDelete(id, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['ToolApi.apiV1ToolsIdDelete']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Get tool + * @summary Get Tool + * @param {string} id Tool ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiV1ToolsIdGet(id: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1ToolsIdGet(id, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['ToolApi.apiV1ToolsIdGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Create tool + * @summary Create Tool + * @param {RagNewInternalSchemaToolCreateRequest} tool Tool + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async apiV1ToolsPost(tool: RagNewInternalSchemaToolCreateRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1ToolsPost(tool, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['ToolApi.apiV1ToolsPost']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + } +}; + +/** + * ToolApi - factory interface + * @export + */ +export const ToolApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = ToolApiFp(configuration) + return { + /** + * List tools + * @summary List Tool + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ToolsGet(options?: any): AxiosPromise { + return localVarFp.apiV1ToolsGet(options).then((request) => request(axios, basePath)); + }, + /** + * DeleteTool + * @summary DeleteTool + * @param {string} id Tool ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ToolsIdDelete(id: string, options?: any): AxiosPromise { + return localVarFp.apiV1ToolsIdDelete(id, options).then((request) => request(axios, basePath)); + }, + /** + * Get tool + * @summary Get Tool + * @param {string} id Tool ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ToolsIdGet(id: string, options?: any): AxiosPromise { + return localVarFp.apiV1ToolsIdGet(id, options).then((request) => request(axios, basePath)); + }, + /** + * Create tool + * @summary Create Tool + * @param {RagNewInternalSchemaToolCreateRequest} tool Tool + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + apiV1ToolsPost(tool: RagNewInternalSchemaToolCreateRequest, options?: any): AxiosPromise { + return localVarFp.apiV1ToolsPost(tool, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * ToolApi - object-oriented interface + * @export + * @class ToolApi + * @extends {BaseAPI} + */ +export class ToolApi extends BaseAPI { + /** + * List tools + * @summary List Tool + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ToolApi + */ + public apiV1ToolsGet(options?: RawAxiosRequestConfig) { + return ToolApiFp(this.configuration).apiV1ToolsGet(options).then((request) => request(this.axios, this.basePath)); + } + + /** + * DeleteTool + * @summary DeleteTool + * @param {string} id Tool ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ToolApi + */ + public apiV1ToolsIdDelete(id: string, options?: RawAxiosRequestConfig) { + return ToolApiFp(this.configuration).apiV1ToolsIdDelete(id, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Get tool + * @summary Get Tool + * @param {string} id Tool ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ToolApi + */ + public apiV1ToolsIdGet(id: string, options?: RawAxiosRequestConfig) { + return ToolApiFp(this.configuration).apiV1ToolsIdGet(id, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Create tool + * @summary Create Tool + * @param {RagNewInternalSchemaToolCreateRequest} tool Tool + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ToolApi + */ + public apiV1ToolsPost(tool: RagNewInternalSchemaToolCreateRequest, options?: RawAxiosRequestConfig) { + return ToolApiFp(this.configuration).apiV1ToolsPost(tool, options).then((request) => request(this.axios, this.basePath)); + } +} + + + diff --git a/src/api/base.ts b/src/api/base.ts new file mode 100644 index 0000000..492934a --- /dev/null +++ b/src/api/base.ts @@ -0,0 +1,86 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Leaflow Amber + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import type { Configuration } from './configuration'; +// Some imports not used depending on template conditions +// @ts-ignore +import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios'; +import globalAxios from 'axios'; + +export const BASE_PATH = "http://localhost".replace(/\/+$/, ""); + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +/** + * + * @export + * @interface RequestArgs + */ +export interface RequestArgs { + url: string; + options: RawAxiosRequestConfig; +} + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPI { + protected configuration: Configuration | undefined; + + constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { + if (configuration) { + this.configuration = configuration; + this.basePath = configuration.basePath ?? basePath; + } + } +}; + +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +export class RequiredError extends Error { + constructor(public field: string, msg?: string) { + super(msg); + this.name = "RequiredError" + } +} + +interface ServerMap { + [key: string]: { + url: string, + description: string, + }[]; +} + +/** + * + * @export + */ +export const operationServerMap: ServerMap = { +} diff --git a/src/api/common.ts b/src/api/common.ts new file mode 100644 index 0000000..c3f1cd7 --- /dev/null +++ b/src/api/common.ts @@ -0,0 +1,150 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Leaflow Amber + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import type { Configuration } from "./configuration"; +import type { RequestArgs } from "./base"; +import type { AxiosInstance, AxiosResponse } from 'axios'; +import { RequiredError } from "./base"; + +/** + * + * @export + */ +export const DUMMY_BASE_URL = 'https://example.com' + +/** + * + * @throws {RequiredError} + * @export + */ +export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) { + if (paramValue === null || paramValue === undefined) { + throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); + } +} + +/** + * + * @export + */ +export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) { + if (configuration && configuration.apiKey) { + const localVarApiKeyValue = typeof configuration.apiKey === 'function' + ? await configuration.apiKey(keyParamName) + : await configuration.apiKey; + object[keyParamName] = localVarApiKeyValue; + } +} + +/** + * + * @export + */ +export const setBasicAuthToObject = function (object: any, configuration?: Configuration) { + if (configuration && (configuration.username || configuration.password)) { + object["auth"] = { username: configuration.username, password: configuration.password }; + } +} + +/** + * + * @export + */ +export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) { + if (configuration && configuration.accessToken) { + const accessToken = typeof configuration.accessToken === 'function' + ? await configuration.accessToken() + : await configuration.accessToken; + object["Authorization"] = "Bearer " + accessToken; + } +} + +/** + * + * @export + */ +export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) { + if (configuration && configuration.accessToken) { + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' + ? await configuration.accessToken(name, scopes) + : await configuration.accessToken; + object["Authorization"] = "Bearer " + localVarAccessTokenValue; + } +} + +function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { + if (parameter == null) return; + if (typeof parameter === "object") { + if (Array.isArray(parameter)) { + (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); + } + else { + Object.keys(parameter).forEach(currentKey => + setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`) + ); + } + } + else { + if (urlSearchParams.has(key)) { + urlSearchParams.append(key, parameter); + } + else { + urlSearchParams.set(key, parameter); + } + } +} + +/** + * + * @export + */ +export const setSearchParams = function (url: URL, ...objects: any[]) { + const searchParams = new URLSearchParams(url.search); + setFlattenedQueryParams(searchParams, objects); + url.search = searchParams.toString(); +} + +/** + * + * @export + */ +export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) { + const nonString = typeof value !== 'string'; + const needsSerialization = nonString && configuration && configuration.isJsonMime + ? configuration.isJsonMime(requestOptions.headers['Content-Type']) + : nonString; + return needsSerialization + ? JSON.stringify(value !== undefined ? value : {}) + : (value || ""); +} + +/** + * + * @export + */ +export const toPathString = function (url: URL) { + return url.pathname + url.search + url.hash +} + +/** + * + * @export + */ +export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) { + return >(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url}; + return axios.request(axiosRequestArgs); + }; +} diff --git a/src/api/configuration.ts b/src/api/configuration.ts new file mode 100644 index 0000000..85860d9 --- /dev/null +++ b/src/api/configuration.ts @@ -0,0 +1,110 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Leaflow Amber + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface ConfigurationParameters { + apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); + username?: string; + password?: string; + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); + basePath?: string; + serverIndex?: number; + baseOptions?: any; + formDataCtor?: new () => any; +} + +export class Configuration { + /** + * parameter for apiKey security + * @param name security name + * @memberof Configuration + */ + apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + username?: string; + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + password?: string; + /** + * parameter for oauth2 security + * @param name security name + * @param scopes oauth2 scope + * @memberof Configuration + */ + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); + /** + * override base path + * + * @type {string} + * @memberof Configuration + */ + basePath?: string; + /** + * override server index + * + * @type {number} + * @memberof Configuration + */ + serverIndex?: number; + /** + * base options for axios calls + * + * @type {any} + * @memberof Configuration + */ + baseOptions?: any; + /** + * The FormData constructor that will be used to create multipart form data + * requests. You can inject this here so that execution environments that + * do not support the FormData class can still run the generated client. + * + * @type {new () => FormData} + */ + formDataCtor?: new () => any; + + constructor(param: ConfigurationParameters = {}) { + this.apiKey = param.apiKey; + this.username = param.username; + this.password = param.password; + this.accessToken = param.accessToken; + this.basePath = param.basePath; + this.serverIndex = param.serverIndex; + this.baseOptions = param.baseOptions; + this.formDataCtor = param.formDataCtor; + } + + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * @param mime - MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + public isJsonMime(mime: string): boolean { + const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); + return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); + } +} diff --git a/src/api/git_push.sh b/src/api/git_push.sh new file mode 100644 index 0000000..f53a75d --- /dev/null +++ b/src/api/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/src/api/index.ts b/src/api/index.ts new file mode 100644 index 0000000..e1dbc5c --- /dev/null +++ b/src/api/index.ts @@ -0,0 +1,18 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Leaflow Amber + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export * from "./api"; +export * from "./configuration"; + diff --git a/src/components.d.ts b/src/components.d.ts index 36531c7..b014648 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -7,9 +7,12 @@ export {} /* prettier-ignore */ declare module 'vue' { export interface GlobalComponents { + AppBar: typeof import('./components/AppBar.vue')['default'] AppFooter: typeof import('./components/AppFooter.vue')['default'] + copy: typeof import('./components/default copy.vue')['default'] HelloWorld: typeof import('./components/HelloWorld.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] + View: typeof import('./components/View.vue')['default'] } } diff --git a/src/layouts/app.vue b/src/components/AppBar.vue similarity index 66% rename from src/layouts/app.vue rename to src/components/AppBar.vue index 7024f6e..8369f45 100644 --- a/src/layouts/app.vue +++ b/src/components/AppBar.vue @@ -5,31 +5,23 @@ - + - - + + diff --git a/src/components/AppFooter.vue b/src/components/AppFooter.vue deleted file mode 100644 index d73cc65..0000000 --- a/src/components/AppFooter.vue +++ /dev/null @@ -1,79 +0,0 @@ - - - - - diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue deleted file mode 100644 index e81db87..0000000 --- a/src/components/HelloWorld.vue +++ /dev/null @@ -1,157 +0,0 @@ - - - diff --git a/src/components/View.vue b/src/components/View.vue new file mode 100644 index 0000000..e69428b --- /dev/null +++ b/src/components/View.vue @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/src/layouts/README.md b/src/layouts/README.md deleted file mode 100644 index 4016af3..0000000 --- a/src/layouts/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Layouts - -Layouts are reusable components that wrap around pages. They are used to provide a consistent look and feel across multiple pages. - -Full documentation for this feature can be found in the Official [vite-plugin-vue-layouts](https://github.com/JohnCampionJr/vite-plugin-vue-layouts) repository. diff --git a/src/layouts/default.vue b/src/layouts/default.vue index da5c129..2e1b378 100644 --- a/src/layouts/default.vue +++ b/src/layouts/default.vue @@ -1,13 +1,15 @@ - diff --git a/src/pages/auth/callback.vue b/src/pages/auth/callback.vue index cfdbb31..484cd2a 100644 --- a/src/pages/auth/callback.vue +++ b/src/pages/auth/callback.vue @@ -6,28 +6,45 @@ diff --git a/src/pages/auth/login.vue b/src/pages/auth/login.vue index 1711eaa..4c7764c 100644 --- a/src/pages/auth/login.vue +++ b/src/pages/auth/login.vue @@ -6,17 +6,17 @@ diff --git a/src/pages/index.vue b/src/pages/index.vue index dac59c7..7639af1 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -1,7 +1,42 @@ diff --git a/src/plugins/api.ts b/src/plugins/api.ts new file mode 100644 index 0000000..7a011eb --- /dev/null +++ b/src/plugins/api.ts @@ -0,0 +1,26 @@ +import {Configuration, ChatApi, AssistantApi, PingApi, ToolApi, ChatMessageApi,} from "@/api"; +import { useConfigStore } from "@/stores/config"; +import { useUserStore } from "@/stores/user"; + +const configStore = useConfigStore() +const userStore = useUserStore() + +const conf = new Configuration + +conf.basePath = configStore.backend +conf.apiKey = "Bearer " + userStore.id_token + + +const api = { + Chat: new ChatApi(conf), + Assistant: new AssistantApi(conf), + Ping: new PingApi(conf), + Tool: new ToolApi(conf), + ChatMessage: new ChatMessageApi(conf), +} + + + +export { + api, conf +} diff --git a/src/stores/README.md b/src/stores/README.md deleted file mode 100644 index 54f8e03..0000000 --- a/src/stores/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Store - -Pinia stores are used to store reactive state and expose actions to mutate it. - -Full documentation for this feature can be found in the Official [Pinia](https://pinia.esm.dev/) repository. diff --git a/src/stores/config.ts b/src/stores/config.ts new file mode 100644 index 0000000..db7296d --- /dev/null +++ b/src/stores/config.ts @@ -0,0 +1,14 @@ +// Utilities +import { defineStore } from 'pinia' + +export const useConfigStore = defineStore('config', { + state: () => ({ + app_name: "Amber", + oauth_discovery_url: "https://auth.leaflow.cn/.well-known/openid-configuration", + oauth_client_id: "14", + oauth_callback_url: "http://localhost:3000/auth/callback", + oauth_storage_key: "code_verifier", + oauth_scope: "openid profile", + backend: "http://localhost:8080" + }), +}) diff --git a/src/stores/index.ts b/src/stores/index.ts index 1536252..c11b279 100644 --- a/src/stores/index.ts +++ b/src/stores/index.ts @@ -1,4 +1,10 @@ // Utilities import { createPinia } from 'pinia' -export default createPinia() +import piniaPluginPersistedstate from 'pinia-plugin-persistedstate' + +const pinia = createPinia() + +pinia.use(piniaPluginPersistedstate) + +export default pinia diff --git a/src/stores/user.ts b/src/stores/user.ts new file mode 100644 index 0000000..83d1beb --- /dev/null +++ b/src/stores/user.ts @@ -0,0 +1,96 @@ +import { defineStore } from "pinia"; +import { useConfigStore } from "@/stores/config"; +import axios from "axios"; +export const useUserStore = defineStore("user", { + persist: true, + state: () => ({ + logined: false, + id_token: "", + refresh_token: "", + access_token: "", + expired_at: 0, + user: { + id: 0, + name: "", + email: "", + }, + timer: 0, + }), + actions: { + login( + id_token: string, + access_token: string, + refresh_token: string, + expired_at: number + ) { + let id_token_parts = id_token.split("."); + let id_token_payload = JSON.parse(atob(id_token_parts[1])); + + expired_at = Date.now() + expired_at * 1000; + this.expired_at = expired_at; + + this.refresh_token = refresh_token; + this.access_token = access_token; + + this.id_token = id_token; + this.user.email = id_token_payload.email; + this.user.name = id_token_payload.name; + this.user.id = id_token_payload.sub; + this.logined = true; + }, + setupTimer() { + // 如果有 timer + if (this.timer) { + return; + } + + this.timer = setInterval(() => { + if (this.logined) { + if (this.expired_at - Date.now() < 60000) { + this.refresh(); + } + // else { + // // 显示还有多长时间过期 + // // console.log("Token will expire in " + (this.expired_at - Date.now()) / 1000 + " seconds"); + // } + } + }, 10 * 1000); + }, + async refresh() { + const configStore = useConfigStore(); + + let discovery = await axios.get(configStore.oauth_discovery_url); + + // post /oauth/token to refresh + // 构建 form 参数 + let data = new URLSearchParams(); + data.set("grant_type", "refresh_token"); + data.set("refresh_token", this.refresh_token); + data.set("client_id", configStore.oauth_client_id); + data.set("scope", configStore.oauth_scope); + + // axios + let refresh = await axios.post(discovery.data.token_endpoint, data); + + this.login( + refresh.data.id_token, + refresh.data.access_token, + refresh.data.refresh_token, + refresh.data.expires_in + ); + }, + logout() { + this.user = { + id: 0, + name: "", + email: "", + }; + + this.id_token = ""; + this.logined = false; + }, + }, +}); + +const userStore = useUserStore(); +userStore.setupTimer(); diff --git a/yarn.lock b/yarn.lock index eb20116..c98b8ca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2345,6 +2345,11 @@ picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.3.1: resolved "https://mirrors.cloud.tencent.com/npm/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== +pinia-plugin-persistedstate@^3.2.1: + version "3.2.1" + resolved "https://mirrors.cloud.tencent.com/npm/pinia-plugin-persistedstate/-/pinia-plugin-persistedstate-3.2.1.tgz#66780602aecd6c7b152dd7e3ddc249a1f7a13fe5" + integrity sha512-MK++8LRUsGF7r45PjBFES82ISnPzyO6IZx3CH5vyPseFLZCk1g2kgx6l/nW8pEBKxxd4do0P6bJw+mUSZIEZUQ== + pinia@^2.1.7: version "2.1.7" resolved "https://mirrors.cloud.tencent.com/npm/pinia/-/pinia-2.1.7.tgz#4cf5420d9324ca00b7b4984d3fbf693222115bbc"