增加 图片上传
Some checks failed
Build / build (push) Failing after 31s

This commit is contained in:
ivamp 2024-08-25 05:55:28 +08:00
parent d928b122be
commit 9bfd461105
3 changed files with 434 additions and 156 deletions

View File

@ -92,6 +92,8 @@ definitions:
type: string
created_at:
type: string
hidden:
type: boolean
id:
type: integer
prompt_tokens:
@ -188,7 +190,7 @@ definitions:
assistant_id:
type: integer
name:
maxLength: 255
maxLength: 30
type: string
required:
- assistant_id
@ -206,6 +208,7 @@ definitions:
- system
- system_hide
- assistant
- image
type: string
required:
- message
@ -252,6 +255,19 @@ definitions:
valid:
type: boolean
type: object
rag-new_internal_schema.FunctionsInput:
properties:
description:
type: string
name:
type: string
parameters:
$ref: '#/definitions/rag-new_internal_schema.ToolDiscoveryOutputFunctionParameters'
required:
- description
- name
- parameters
type: object
rag-new_internal_schema.GetPublicChatMessageRequest:
properties:
assistant_token:
@ -367,24 +383,7 @@ definitions:
type: string
functions:
items:
properties:
description:
type: string
name:
type: string
parameters:
properties:
properties: {}
type:
type: string
type: object
required:
items:
type: string
type: array
required:
- required
type: object
$ref: '#/definitions/rag-new_internal_schema.FunctionsInput'
type: array
homepage_url:
type: string
@ -415,15 +414,26 @@ definitions:
type: string
name:
type: string
parameters: {}
parameters:
$ref: '#/definitions/rag-new_internal_schema.ToolDiscoveryOutputFunctionParameters'
type: object
rag-new_internal_schema.ToolDiscoveryOutputFunctionParameters:
properties:
properties: {}
required:
items:
type: string
type: array
type:
type: string
required:
- properties
- required
- type
type: object
rag-new_internal_schema.ToolDiscoveryOutputFunctions:
properties:
function:
functions:
items:
$ref: '#/definitions/rag-new_internal_schema.ToolDiscoveryOutputFunction'
type: array
@ -458,12 +468,7 @@ paths:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
$ref: '#/definitions/rag-new_internal_schema.OpenAIChatCompletionResponse'
type: object
$ref: '#/definitions/rag-new_internal_schema.OpenAIChatCompletionResponse'
"400":
description: Bad Request
schema:
@ -1120,8 +1125,7 @@ paths:
- application/json
description: 清空当前聊天记录
parameters:
- description: Chat ID
in: path
- in: path
name: id
required: true
type: integer
@ -1151,14 +1155,66 @@ paths:
summary: 清空聊天记录
tags:
- chat_message
/api/v1/chats/{id}/images:
post:
consumes:
- application/json
description: 将一个图片添加到聊天记录中
parameters:
- in: path
name: id
required: true
type: integer
- description: 图片
in: formData
name: image
required: true
type: file
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:
- ApiKeyAuth: []
summary: 添加图片
tags:
- chat_message
/api/v1/chats/{id}/messages:
get:
consumes:
- application/json
description: get string by ID
parameters:
- description: Chat ID
in: path
- in: path
name: id
required: true
type: integer
@ -1198,8 +1254,7 @@ paths:
- application/json
description: get string by ID
parameters:
- description: Chat ID
in: path
- in: path
name: id
required: true
type: integer
@ -1247,6 +1302,26 @@ paths:
summary: 添加聊天记录
tags:
- chat_message
/api/v1/files/{id}/download:
get:
consumes:
- application/json
description: 根据 File ID 下载文件
parameters:
- in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
type: file
summary: 下载文件
tags:
- file
/api/v1/ping:
get:
consumes:
@ -1284,11 +1359,6 @@ paths:
in: header
name: X-User-IP
type: string
- description: Chat ID
in: path
name: id
required: true
type: integer
- description: Chat stream id
in: path
name: stream_id

View File

@ -23,37 +23,6 @@ import type { RequestArgs } from './base';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError, operationServerMap } from './base';
/**
*
* @export
* @interface ApiOpenaiCompatibleV1ChatCompletionsPost200Response
*/
export interface ApiOpenaiCompatibleV1ChatCompletionsPost200Response {
/**
*
* @type {RagNewInternalSchemaOpenAIChatCompletionResponse}
* @memberof ApiOpenaiCompatibleV1ChatCompletionsPost200Response
*/
'data'?: RagNewInternalSchemaOpenAIChatCompletionResponse;
/**
*
* @type {string}
* @memberof ApiOpenaiCompatibleV1ChatCompletionsPost200Response
*/
'error'?: string;
/**
*
* @type {string}
* @memberof ApiOpenaiCompatibleV1ChatCompletionsPost200Response
*/
'message'?: string;
/**
*
* @type {boolean}
* @memberof ApiOpenaiCompatibleV1ChatCompletionsPost200Response
*/
'success'?: boolean;
}
/**
*
* @export
@ -364,6 +333,19 @@ export interface ApiV1ChatPublicPost200Response {
*/
'success'?: boolean;
}
/**
*
* @export
* @interface ApiV1ChatsIdImagesPostRequest
*/
export interface ApiV1ChatsIdImagesPostRequest {
/**
*
* @type {File}
* @memberof ApiV1ChatsIdImagesPostRequest
*/
'image': File;
}
/**
*
* @export
@ -726,6 +708,12 @@ export interface RagNewInternalEntityChatMessage {
* @memberof RagNewInternalEntityChatMessage
*/
'created_at'?: string;
/**
*
* @type {boolean}
* @memberof RagNewInternalEntityChatMessage
*/
'hidden'?: boolean;
/**
*
* @type {number}
@ -966,7 +954,8 @@ export const RagNewInternalSchemaChatMessageAddRequestRoleEnum = {
UserHide: 'user_hide',
System: 'system',
SystemHide: 'system_hide',
Assistant: 'assistant'
Assistant: 'assistant',
Image: 'image'
} as const;
export type RagNewInternalSchemaChatMessageAddRequestRoleEnum = typeof RagNewInternalSchemaChatMessageAddRequestRoleEnum[keyof typeof RagNewInternalSchemaChatMessageAddRequestRoleEnum];
@ -1065,6 +1054,31 @@ export interface RagNewInternalSchemaCurrentUserResponse {
*/
'valid'?: boolean;
}
/**
*
* @export
* @interface RagNewInternalSchemaFunctionsInput
*/
export interface RagNewInternalSchemaFunctionsInput {
/**
*
* @type {string}
* @memberof RagNewInternalSchemaFunctionsInput
*/
'description': string;
/**
*
* @type {string}
* @memberof RagNewInternalSchemaFunctionsInput
*/
'name': string;
/**
*
* @type {RagNewInternalSchemaToolDiscoveryOutputFunctionParameters}
* @memberof RagNewInternalSchemaFunctionsInput
*/
'parameters': RagNewInternalSchemaToolDiscoveryOutputFunctionParameters;
}
/**
*
* @export
@ -1321,10 +1335,10 @@ export interface RagNewInternalSchemaToolDiscoveryInput {
'description': string;
/**
*
* @type {Array<RagNewInternalSchemaToolDiscoveryInputFunctionsInner>}
* @type {Array<RagNewInternalSchemaFunctionsInput>}
* @memberof RagNewInternalSchemaToolDiscoveryInput
*/
'functions'?: Array<RagNewInternalSchemaToolDiscoveryInputFunctionsInner>;
'functions'?: Array<RagNewInternalSchemaFunctionsInput>;
/**
*
* @type {string}
@ -1338,56 +1352,6 @@ export interface RagNewInternalSchemaToolDiscoveryInput {
*/
'name': string;
}
/**
*
* @export
* @interface RagNewInternalSchemaToolDiscoveryInputFunctionsInner
*/
export interface RagNewInternalSchemaToolDiscoveryInputFunctionsInner {
/**
*
* @type {string}
* @memberof RagNewInternalSchemaToolDiscoveryInputFunctionsInner
*/
'description'?: string;
/**
*
* @type {string}
* @memberof RagNewInternalSchemaToolDiscoveryInputFunctionsInner
*/
'name'?: string;
/**
*
* @type {RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParameters}
* @memberof RagNewInternalSchemaToolDiscoveryInputFunctionsInner
*/
'parameters'?: RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParameters;
/**
*
* @type {Array<string>}
* @memberof RagNewInternalSchemaToolDiscoveryInputFunctionsInner
*/
'required': Array<string>;
}
/**
*
* @export
* @interface RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParameters
*/
export interface RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParameters {
/**
*
* @type {object}
* @memberof RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParameters
*/
'properties'?: object;
/**
*
* @type {string}
* @memberof RagNewInternalSchemaToolDiscoveryInputFunctionsInnerParameters
*/
'type'?: string;
}
/**
*
* @export
@ -1445,16 +1409,35 @@ export interface RagNewInternalSchemaToolDiscoveryOutputFunction {
'name'?: string;
/**
*
* @type {object}
* @type {RagNewInternalSchemaToolDiscoveryOutputFunctionParameters}
* @memberof RagNewInternalSchemaToolDiscoveryOutputFunction
*/
'parameters'?: object;
'parameters'?: RagNewInternalSchemaToolDiscoveryOutputFunctionParameters;
}
/**
*
* @export
* @interface RagNewInternalSchemaToolDiscoveryOutputFunctionParameters
*/
export interface RagNewInternalSchemaToolDiscoveryOutputFunctionParameters {
/**
*
* @type {object}
* @memberof RagNewInternalSchemaToolDiscoveryOutputFunctionParameters
*/
'properties': object;
/**
*
* @type {Array<string>}
* @memberof RagNewInternalSchemaToolDiscoveryOutputFunction
* @memberof RagNewInternalSchemaToolDiscoveryOutputFunctionParameters
*/
'required'?: Array<string>;
'required': Array<string>;
/**
*
* @type {string}
* @memberof RagNewInternalSchemaToolDiscoveryOutputFunctionParameters
*/
'type': string;
}
/**
*
@ -1467,7 +1450,7 @@ export interface RagNewInternalSchemaToolDiscoveryOutputFunctions {
* @type {Array<RagNewInternalSchemaToolDiscoveryOutputFunction>}
* @memberof RagNewInternalSchemaToolDiscoveryOutputFunctions
*/
'function'?: Array<RagNewInternalSchemaToolDiscoveryOutputFunction>;
'functions'?: Array<RagNewInternalSchemaToolDiscoveryOutputFunction>;
/**
*
* @type {string}
@ -2514,7 +2497,7 @@ export const ChatApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiOpenaiCompatibleV1ChatCompletionsPost(chat: RagNewInternalSchemaOpenAIChatCompletionRequest, xUserIP?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ApiOpenaiCompatibleV1ChatCompletionsPost200Response>> {
async apiOpenaiCompatibleV1ChatCompletionsPost(chat: RagNewInternalSchemaOpenAIChatCompletionRequest, xUserIP?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<RagNewInternalSchemaOpenAIChatCompletionResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.apiOpenaiCompatibleV1ChatCompletionsPost(chat, xUserIP, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['ChatApi.apiOpenaiCompatibleV1ChatCompletionsPost']?.[localVarOperationServerIndex]?.url;
@ -2577,7 +2560,7 @@ export const ChatApiFactory = function (configuration?: Configuration, basePath?
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiOpenaiCompatibleV1ChatCompletionsPost(chat: RagNewInternalSchemaOpenAIChatCompletionRequest, xUserIP?: string, options?: any): AxiosPromise<ApiOpenaiCompatibleV1ChatCompletionsPost200Response> {
apiOpenaiCompatibleV1ChatCompletionsPost(chat: RagNewInternalSchemaOpenAIChatCompletionRequest, xUserIP?: string, options?: any): AxiosPromise<RagNewInternalSchemaOpenAIChatCompletionResponse> {
return localVarFp.apiOpenaiCompatibleV1ChatCompletionsPost(chat, xUserIP, options).then((request) => request(axios, basePath));
},
/**
@ -2681,7 +2664,7 @@ export const ChatMessageApiAxiosParamCreator = function (configuration?: Configu
/**
*
* @summary
* @param {number} id Chat ID
* @param {number} id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
@ -2715,10 +2698,53 @@ export const ChatMessageApiAxiosParamCreator = function (configuration?: Configu
options: localVarRequestOptions,
};
},
/**
*
* @summary
* @param {number} id
* @param {ApiV1ChatsIdImagesPostRequest} apiV1ChatsIdImagesPostRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiV1ChatsIdImagesPost: async (id: number, apiV1ChatsIdImagesPostRequest: ApiV1ChatsIdImagesPostRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'id' is not null or undefined
assertParamExists('apiV1ChatsIdImagesPost', 'id', id)
// verify required parameter 'apiV1ChatsIdImagesPostRequest' is not null or undefined
assertParamExists('apiV1ChatsIdImagesPost', 'apiV1ChatsIdImagesPostRequest', apiV1ChatsIdImagesPostRequest)
const localVarPath = `/api/v1/chats/{id}/images`
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication ApiKeyAuth required
await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration)
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(apiV1ChatsIdImagesPostRequest, localVarRequestOptions, configuration)
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* get string by ID
* @summary
* @param {number} id Chat ID
* @param {number} id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
@ -2755,7 +2781,7 @@ export const ChatMessageApiAxiosParamCreator = function (configuration?: Configu
/**
* get string by ID
* @summary
* @param {number} id Chat ID
* @param {number} id
* @param {RagNewInternalSchemaChatMessageAddRequest} message Message
* @param {*} [options] Override http request option.
* @throws {RequiredError}
@ -2798,19 +2824,15 @@ export const ChatMessageApiAxiosParamCreator = function (configuration?: Configu
/**
* get string by ID
* @summary
* @param {number} id Chat ID
* @param {string} streamId Chat stream id
* @param {string} [xUserIP] IP IP Prompt Prompt
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiV1StreamStreamIdGet: async (id: number, streamId: string, xUserIP?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'id' is not null or undefined
assertParamExists('apiV1StreamStreamIdGet', 'id', id)
apiV1StreamStreamIdGet: async (streamId: string, xUserIP?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// 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);
@ -2851,7 +2873,7 @@ export const ChatMessageApiFp = function(configuration?: Configuration) {
/**
*
* @summary
* @param {number} id Chat ID
* @param {number} id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
@ -2861,10 +2883,24 @@ export const ChatMessageApiFp = function(configuration?: Configuration) {
const localVarOperationServerBasePath = operationServerMap['ChatMessageApi.apiV1ChatsIdClearPost']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
*
* @summary
* @param {number} id
* @param {ApiV1ChatsIdImagesPostRequest} apiV1ChatsIdImagesPostRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiV1ChatsIdImagesPost(id: number, apiV1ChatsIdImagesPostRequest: ApiV1ChatsIdImagesPostRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ApiV1ChatPublicChatIdMessagesPost200Response>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1ChatsIdImagesPost(id, apiV1ChatsIdImagesPostRequest, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['ChatMessageApi.apiV1ChatsIdImagesPost']?.[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 {number} id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
@ -2877,7 +2913,7 @@ export const ChatMessageApiFp = function(configuration?: Configuration) {
/**
* get string by ID
* @summary
* @param {number} id Chat ID
* @param {number} id
* @param {RagNewInternalSchemaChatMessageAddRequest} message Message
* @param {*} [options] Override http request option.
* @throws {RequiredError}
@ -2891,14 +2927,13 @@ export const ChatMessageApiFp = function(configuration?: Configuration) {
/**
* get string by ID
* @summary
* @param {number} id Chat ID
* @param {string} streamId Chat stream id
* @param {string} [xUserIP] IP IP Prompt Prompt
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiV1StreamStreamIdGet(id: number, streamId: string, xUserIP?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ApiV1ChatPublicChatIdMessagesPost200Response>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1StreamStreamIdGet(id, streamId, xUserIP, options);
async apiV1StreamStreamIdGet(streamId: string, xUserIP?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ApiV1ChatPublicChatIdMessagesPost200Response>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1StreamStreamIdGet(streamId, xUserIP, 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);
@ -2916,17 +2951,28 @@ export const ChatMessageApiFactory = function (configuration?: Configuration, ba
/**
*
* @summary
* @param {number} id Chat ID
* @param {number} id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiV1ChatsIdClearPost(id: number, options?: any): AxiosPromise<void> {
return localVarFp.apiV1ChatsIdClearPost(id, options).then((request) => request(axios, basePath));
},
/**
*
* @summary
* @param {number} id
* @param {ApiV1ChatsIdImagesPostRequest} apiV1ChatsIdImagesPostRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiV1ChatsIdImagesPost(id: number, apiV1ChatsIdImagesPostRequest: ApiV1ChatsIdImagesPostRequest, options?: any): AxiosPromise<ApiV1ChatPublicChatIdMessagesPost200Response> {
return localVarFp.apiV1ChatsIdImagesPost(id, apiV1ChatsIdImagesPostRequest, options).then((request) => request(axios, basePath));
},
/**
* get string by ID
* @summary
* @param {number} id Chat ID
* @param {number} id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
@ -2936,7 +2982,7 @@ export const ChatMessageApiFactory = function (configuration?: Configuration, ba
/**
* get string by ID
* @summary
* @param {number} id Chat ID
* @param {number} id
* @param {RagNewInternalSchemaChatMessageAddRequest} message Message
* @param {*} [options] Override http request option.
* @throws {RequiredError}
@ -2947,14 +2993,13 @@ export const ChatMessageApiFactory = function (configuration?: Configuration, ba
/**
* get string by ID
* @summary
* @param {number} id Chat ID
* @param {string} streamId Chat stream id
* @param {string} [xUserIP] IP IP Prompt Prompt
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiV1StreamStreamIdGet(id: number, streamId: string, xUserIP?: string, options?: any): AxiosPromise<ApiV1ChatPublicChatIdMessagesPost200Response> {
return localVarFp.apiV1StreamStreamIdGet(id, streamId, xUserIP, options).then((request) => request(axios, basePath));
apiV1StreamStreamIdGet(streamId: string, xUserIP?: string, options?: any): AxiosPromise<ApiV1ChatPublicChatIdMessagesPost200Response> {
return localVarFp.apiV1StreamStreamIdGet(streamId, xUserIP, options).then((request) => request(axios, basePath));
},
};
};
@ -2969,7 +3014,7 @@ export class ChatMessageApi extends BaseAPI {
/**
*
* @summary
* @param {number} id Chat ID
* @param {number} id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ChatMessageApi
@ -2978,10 +3023,23 @@ export class ChatMessageApi extends BaseAPI {
return ChatMessageApiFp(this.configuration).apiV1ChatsIdClearPost(id, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary
* @param {number} id
* @param {ApiV1ChatsIdImagesPostRequest} apiV1ChatsIdImagesPostRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ChatMessageApi
*/
public apiV1ChatsIdImagesPost(id: number, apiV1ChatsIdImagesPostRequest: ApiV1ChatsIdImagesPostRequest, options?: RawAxiosRequestConfig) {
return ChatMessageApiFp(this.configuration).apiV1ChatsIdImagesPost(id, apiV1ChatsIdImagesPostRequest, options).then((request) => request(this.axios, this.basePath));
}
/**
* get string by ID
* @summary
* @param {number} id Chat ID
* @param {number} id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ChatMessageApi
@ -2993,7 +3051,7 @@ export class ChatMessageApi extends BaseAPI {
/**
* get string by ID
* @summary
* @param {number} id Chat ID
* @param {number} id
* @param {RagNewInternalSchemaChatMessageAddRequest} message Message
* @param {*} [options] Override http request option.
* @throws {RequiredError}
@ -3006,15 +3064,14 @@ export class ChatMessageApi extends BaseAPI {
/**
* get string by ID
* @summary
* @param {number} id Chat ID
* @param {string} streamId Chat stream id
* @param {string} [xUserIP] IP IP Prompt Prompt
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ChatMessageApi
*/
public apiV1StreamStreamIdGet(id: number, streamId: string, xUserIP?: string, options?: RawAxiosRequestConfig) {
return ChatMessageApiFp(this.configuration).apiV1StreamStreamIdGet(id, streamId, xUserIP, options).then((request) => request(this.axios, this.basePath));
public apiV1StreamStreamIdGet(streamId: string, xUserIP?: string, options?: RawAxiosRequestConfig) {
return ChatMessageApiFp(this.configuration).apiV1StreamStreamIdGet(streamId, xUserIP, options).then((request) => request(this.axios, this.basePath));
}
}
@ -3446,6 +3503,114 @@ export class ChatPublicApi extends BaseAPI {
/**
* FileApi - axios parameter creator
* @export
*/
export const FileApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
* File ID
* @summary
* @param {number} id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiV1FilesIdDownloadGet: async (id: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'id' is not null or undefined
assertParamExists('apiV1FilesIdDownloadGet', 'id', id)
const localVarPath = `/api/v1/files/{id}/download`
.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,
};
},
}
};
/**
* FileApi - functional programming interface
* @export
*/
export const FileApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = FileApiAxiosParamCreator(configuration)
return {
/**
* File ID
* @summary
* @param {number} id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiV1FilesIdDownloadGet(id: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<File>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.apiV1FilesIdDownloadGet(id, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['FileApi.apiV1FilesIdDownloadGet']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
}
};
/**
* FileApi - factory interface
* @export
*/
export const FileApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = FileApiFp(configuration)
return {
/**
* File ID
* @summary
* @param {number} id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiV1FilesIdDownloadGet(id: number, options?: any): AxiosPromise<File> {
return localVarFp.apiV1FilesIdDownloadGet(id, options).then((request) => request(axios, basePath));
},
};
};
/**
* FileApi - object-oriented interface
* @export
* @class FileApi
* @extends {BaseAPI}
*/
export class FileApi extends BaseAPI {
/**
* File ID
* @summary
* @param {number} id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof FileApi
*/
public apiV1FilesIdDownloadGet(id: number, options?: RawAxiosRequestConfig) {
return FileApiFp(this.configuration).apiV1FilesIdDownloadGet(id, options).then((request) => request(this.axios, this.basePath));
}
}
/**
* PingApi - axios parameter creator
* @export

View File

@ -68,7 +68,17 @@
label="输入消息"
@keyup.enter="sendMessage"
></v-text-field>
<v-file-input v-model="fileUpload" label="选择图片"></v-file-input>
<v-btn color="primary" @click="sendMessage">发送</v-btn>
<v-btn
class="ml-2"
color="primary"
:loading="uploading"
@click="uploadImage"
>上传图片</v-btn
>
<v-btn class="ml-2" color="primary" @click="clearMessages">清空</v-btn>
<v-btn class="ml-2" color="primary" @click="deleteChat">删除</v-btn>
</div>
@ -96,7 +106,8 @@ const input = ref("");
const toolName = ref("");
const toolError = ref(false);
const toolCalling = ref(false);
const fileUpload = ref();
const uploading = ref(false);
const imageBaseUrl = config.backend + "/api/v1/files";
function sendMessage() {
@ -236,5 +247,37 @@ const deleteChat = () => {
});
};
const uploadImage = () => {
if (!fileUpload.value) {
return;
}
uploading.value = true;
api.ChatMessage.apiV1ChatsIdImagesPost(
chatId,
{
image: fileUpload.value,
},
{
headers: {
"Content-Type": "multipart/form-data",
},
},
)
.then((r) => {
//
if (r.status === 200 || r.status === 201) {
fileUpload.value = null;
getMessages();
}
})
.catch((err) => {
alert(err.response.data.message);
})
.finally(() => {
uploading.value = false;
});
};
getMessages();
</script>