definitions: entity.Assistant: properties: created_at: type: string description: type: string disable_default_prompt: type: boolean disable_memory: type: boolean enable_memory_for_assistant_api: type: boolean id: description: Id schema.EntityId `gorm:"primarykey" json:"id,string"` type: integer library_id: type: integer name: type: string prompt: type: string temperature: type: number updated_at: type: string user_id: type: string type: object entity.AssistantKey: properties: assistant: $ref: '#/definitions/entity.Assistant' assistant_id: type: integer created_at: type: string id: description: Id schema.EntityId `gorm:"primarykey" json:"id,string"` type: integer secret: type: string updated_at: type: string type: object entity.AssistantTool: properties: assistant: $ref: '#/definitions/entity.Assistant' assistant_id: type: integer created_at: type: string id: description: Id schema.EntityId `gorm:"primarykey" json:"id,string"` type: integer tool: $ref: '#/definitions/entity.Tool' tool_id: type: integer updated_at: type: string type: object entity.Chat: properties: assistant_id: type: integer created_at: type: string expired_at: type: string guest_id: type: string id: description: Id schema.EntityId `gorm:"primarykey" json:"id,string"` type: integer name: type: string owner: type: string updated_at: type: string user_id: type: string type: object entity.ChatMessage: properties: assistant: $ref: '#/definitions/entity.Assistant' assistant_id: description: AssistantId 可以让同一个对话中,使用不同的助手来处理消息 type: integer chat_id: type: integer completion_tokens: type: integer content: type: string created_at: type: string file: $ref: '#/definitions/entity.File' file_id: description: FileId type: integer hidden: description: |- UserFileId *schema.EntityId `json:"user_file_id"` UserFile *UserFile `json:"user_file"` type: boolean id: description: Id schema.EntityId `gorm:"primarykey" json:"id,string"` type: integer prompt_tokens: type: integer role: type: string total_tokens: type: integer updated_at: type: string type: object entity.ChatMessageList: properties: assistant: properties: id: type: integer name: type: string type: object assistant_id: type: integer chat_id: type: integer completion_tokens: type: integer content: type: string created_at: type: string file: $ref: '#/definitions/entity.File' file_id: type: integer hidden: description: |- UserFileId *schema.EntityId `json:"user_file_id"` UserFile *UserFile `json:"user_file"` type: boolean id: type: integer prompt_tokens: type: integer role: type: string total_tokens: type: integer updated_at: type: string type: object entity.Document: properties: chunked: type: boolean created_at: type: string id: description: Id schema.EntityId `gorm:"primarykey" json:"id,string"` type: integer library: $ref: '#/definitions/entity.Library' library_id: type: integer name: type: string updated_at: type: string type: object entity.File: properties: created_at: type: string expired_at: description: |- Public bool `json:"public"` // 是否公开,访客上传的文件应始终公开,或归属于所有者 TODO: 移除 file 的到期时间,如果当 file 没有任何引用的时候再删除 因为有外键,所以直接删除是删不掉的,必须删除消息 type: string file_hash: type: string id: description: Id schema.EntityId `gorm:"primarykey" json:"id,string"` type: integer mime_type: type: string size: type: integer updated_at: type: string url: type: string url_hash: type: string type: object entity.Library: properties: created_at: type: string default: type: boolean description: type: string documents: items: $ref: '#/definitions/entity.Document' type: array id: description: Id schema.EntityId `gorm:"primarykey" json:"id,string"` type: integer name: type: string updated_at: type: string user_id: type: string type: object entity.Memory: properties: content: type: string created_at: type: string id: description: Id schema.EntityId `gorm:"primarykey" json:"id,string"` type: integer updated_at: type: string user_id: type: string type: object entity.Tool: properties: api_key: type: string created_at: type: string data: $ref: '#/definitions/schema.ToolDiscoveryOutput' description: type: string discovery_url: type: string id: description: Id schema.EntityId `gorm:"primarykey" json:"id,string"` type: integer name: type: string updated_at: type: string user_id: type: string type: object schema.AddPublicChatMessageRequest: properties: assistant_key: type: string guest_id: type: string message: type: string role: enum: - user - user_hide - system - system_hide - assistant type: string required: - assistant_key - guest_id - message - role type: object schema.AssistantCreateRequest: properties: description: maxLength: 255 type: string disable_default_prompt: enum: - true - false type: boolean name: maxLength: 255 type: string prompt: maxLength: 512 type: string temperature: enum: - 0.1 - 0.2 - 0.3 - 0.4 - 0.5 - 0.6 - 0.7 - 0.8 - 0.9 - 1 type: number required: - description - name type: object schema.AssistantLibraryRequest: properties: library_id: type: integer required: - library_id type: object schema.AssistantUpdateRequest: properties: description: maxLength: 255 type: string disable_default_prompt: enum: - true - false type: boolean disable_memory: enum: - true - false type: boolean enable_memory_for_assistant_api: enum: - true - false type: boolean library_id: type: integer name: maxLength: 255 type: string prompt: maxLength: 512 type: string temperature: enum: - 0.1 - 0.2 - 0.3 - 0.4 - 0.5 - 0.6 - 0.7 - 0.8 - 0.9 - 1 type: number type: object schema.ChatCreateRequest: properties: assistant_id: type: integer expired_at: $ref: '#/definitions/schema.CustomTime' name: maxLength: 30 type: string required: - name type: object schema.ChatMessageAddRequest: properties: assistant_id: type: integer message: maxLength: 255 type: string role: enum: - user - user_hide - system - system_hide - assistant - image type: string variables: additionalProperties: type: string type: object required: - message - role type: object schema.ChatMessageResponse: properties: stream: type: boolean stream_id: type: string type: object schema.ChatPublicListRequest: properties: guest_id: type: string required: - guest_id type: object schema.ChatPublicRequest: properties: assistant_key: type: string guest_id: type: string name: maxLength: 32 type: string required: - assistant_key - guest_id - name type: object schema.ChatUpdateRequest: properties: assistant_id: type: integer expired_at: $ref: '#/definitions/schema.CustomTime' name: maxLength: 30 type: string required: - name type: object schema.CurrentUserResponse: properties: ip: type: string userEmail: type: string userId: type: string userName: type: string valid: type: boolean type: object schema.CustomTime: properties: time.Time: type: string type: object schema.DocumentCreateRequest: properties: content: type: string name: type: string required: - content - name type: object schema.FunctionsInput: properties: description: type: string name: type: string parameters: $ref: '#/definitions/schema.ToolDiscoveryOutputFunctionParameters' required: - description - name - parameters type: object schema.GetPublicChatMessageRequest: properties: assistant_key: type: string guest_id: type: string required: - assistant_key - guest_id type: object schema.LibraryCreateRequest: properties: description: type: string name: type: string required: - name type: object schema.LibraryUpdateRequest: properties: default: type: boolean description: type: string name: type: string required: - name type: object schema.OpenAIChatCompletionRequest: properties: max_tokens: description: Optional type: integer messages: description: Required items: $ref: '#/definitions/schema.OpenAIChatCompletionRequestMessage' type: array model: description: Required type: string "n": description: Optional type: integer stream: description: Optional type: boolean temperature: description: Optional type: number top_p: description: Optional type: number type: object schema.OpenAIChatCompletionRequestMessage: properties: content: description: Required image_url: $ref: '#/definitions/schema.OpenAIImageUrl' role: description: Required type: string type: object schema.OpenAIChatCompletionResponse: properties: choices: items: $ref: '#/definitions/schema.OpenAIChatCompletionResponseChoice' type: array created: type: integer id: type: string model: type: string object: type: string usage: $ref: '#/definitions/schema.TokenUsage' type: object schema.OpenAIChatCompletionResponseChoice: properties: index: type: integer message: $ref: '#/definitions/schema.OpenAIChatCompletionRequestMessage' type: object schema.OpenAIImageUrl: properties: detail: type: string url: type: string type: object schema.ResponseBody: properties: data: {} error: type: string message: type: string success: type: boolean type: object schema.TokenUsage: properties: completion_tokens: type: integer prompt_tokens: type: integer total_tokens: type: integer type: object schema.ToolCreateRequest: properties: api_key: maxLength: 255 type: string description: maxLength: 255 type: string discovery_url: maxLength: 255 type: string name: maxLength: 255 type: string required: - description - discovery_url - name type: object schema.ToolDiscoveryInput: properties: callback_url: type: string description: type: string functions: items: $ref: '#/definitions/schema.FunctionsInput' type: array homepage_url: type: string name: type: string required: - description - name type: object schema.ToolDiscoveryOutput: properties: callback_url: type: string description: type: string function: items: $ref: '#/definitions/schema.ToolDiscoveryOutputFunctions' type: array homepage_url: type: string name: type: string type: object schema.ToolDiscoveryOutputFunction: properties: description: type: string name: type: string parameters: $ref: '#/definitions/schema.ToolDiscoveryOutputFunctionParameters' type: object schema.ToolDiscoveryOutputFunctionParameters: properties: properties: {} required: items: type: string type: array type: type: string required: - properties - required - type type: object schema.ToolDiscoveryOutputFunctions: properties: functions: items: $ref: '#/definitions/schema.ToolDiscoveryOutputFunction' type: array type: type: string type: object info: contact: {} title: Leaflow Amber version: "1.0" paths: /api/openai-compatible/v1/chat/completions: post: consumes: - application/json description: 兼容 OpenAI Chat Completion 接口,认证需要使用 Assistant Share Token parameters: - description: 指定聊天中的用户 IP 地址,不指定则自动获取。此 IP 地址只会增加至 Prompt 中,如果不希望增加,请关闭系统自带 Prompt 选项 in: header name: X-User-IP type: string - description: Chat in: body name: chat required: true schema: $ref: '#/definitions/schema.OpenAIChatCompletionRequest' produces: - application/json responses: "200": description: OK schema: $ref: '#/definitions/schema.OpenAIChatCompletionResponse' "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' "500": description: Internal Server Error schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: OpenAI Chat Completion tags: - chat /api/v1/assistants: get: consumes: - application/json produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: items: $ref: '#/definitions/entity.Assistant' type: array type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 获取 Assistant 列表 tags: - assistant post: consumes: - application/json parameters: - description: Assistant in: body name: assistant required: true schema: $ref: '#/definitions/schema.AssistantCreateRequest' produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/entity.Assistant' type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 创建 Assistant tags: - assistant /api/v1/assistants/{id}: delete: consumes: - application/json parameters: - description: Assistant ID in: path name: id required: true type: integer produces: - application/json responses: "204": description: No Content "404": description: Not Found schema: $ref: '#/definitions/schema.ResponseBody' "500": description: Internal Server Error schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 删除 Assistant tags: - assistant get: consumes: - application/json parameters: - description: Assistant ID in: path name: id required: true type: integer produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/entity.Assistant' type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 获取指定的 Assistant tags: - assistant put: consumes: - application/json parameters: - description: Assistant ID in: path name: id required: true type: integer - description: Assistant Update in: body name: assistantUpdateRequest required: true schema: $ref: '#/definitions/schema.AssistantUpdateRequest' produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/entity.Assistant' type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 更新 Assistant tags: - assistant /api/v1/assistants/{id}/keys: get: consumes: - application/json description: 此 API 可以创建一个 Assistant API Key,可以将你的 Assistant 公开出去使用。 parameters: - in: path name: id required: true type: integer produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: items: $ref: '#/definitions/entity.AssistantKey' type: array type: object "500": description: Internal Server Error schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 获取 Assistant API Key列表 tags: - assistant post: consumes: - application/json description: 此方法将会获取一个 Token,用户将会通过这个 Token 来访问你的 Assistant 并调用工具。 parameters: - in: path name: id required: true type: integer produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/entity.AssistantKey' type: object "500": description: Internal Server Error schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 创建 Assistant API Key tags: - assistant /api/v1/assistants/{id}/keys/{key_id}: delete: consumes: - application/json description: 此方法将会删除API Key,删除后,API Key将会立即失效。 parameters: - in: path name: id required: true type: integer - in: path name: key_id required: true type: integer produces: - application/json responses: "200": description: OK schema: $ref: '#/definitions/schema.ResponseBody' "500": description: Internal Server Error schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 删除 Assistant API Key tags: - assistant /api/v1/assistants/{id}/library: delete: consumes: - application/json parameters: - in: path name: id required: true type: integer produces: - application/json responses: "204": description: No Content "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 解绑资料库 tags: - assistant post: consumes: - application/json parameters: - in: path name: id required: true type: integer - description: AssistantLibraryRequest in: body name: AssistantLibraryRequest required: true schema: $ref: '#/definitions/schema.AssistantLibraryRequest' produces: - application/json responses: "204": description: No Content "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 绑定资料库 tags: - assistant /api/v1/assistants/{id}/tools: get: consumes: - application/json parameters: - description: Assistant ID in: path name: id required: true type: integer produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: items: $ref: '#/definitions/entity.AssistantTool' type: array type: object "500": description: Internal Server Error schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 获取 Assistant 所绑定的 Tool tags: - assistant /api/v1/assistants/{id}/tools/{tool_id}: delete: consumes: - application/json 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/schema.ResponseBody' - properties: data: $ref: '#/definitions/entity.AssistantTool' type: object "500": description: Internal Server Error schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 解绑 Tool tags: - assistant post: consumes: - application/json 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/schema.ResponseBody' - properties: data: $ref: '#/definitions/entity.AssistantTool' type: object "500": description: Internal Server Error schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 绑定 Tool tags: - assistant /api/v1/chat_public: get: consumes: - application/json parameters: - description: ChatPublicListRequest in: body name: schema.ChatPublicListRequest required: true schema: $ref: '#/definitions/schema.ChatPublicListRequest' produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: items: $ref: '#/definitions/entity.Chat' type: array type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' summary: 获取公开对话 tags: - chat_public post: consumes: - application/json parameters: - description: ChatPublicRequest in: body name: schema.ChatPublicRequest required: true schema: $ref: '#/definitions/schema.ChatPublicRequest' produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/entity.Chat' type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' summary: 通过 API 创建一个公开的对话记录 tags: - chat_public /api/v1/chat_public/{chat_id}/clear: post: consumes: - application/json parameters: - in: path name: chat_id required: true type: integer - description: GetPublicChatMessageRequest in: body name: schema.GetPublicChatMessageRequest required: true schema: $ref: '#/definitions/schema.GetPublicChatMessageRequest' produces: - application/json responses: "200": description: OK "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' "404": description: Not Found schema: $ref: '#/definitions/schema.ResponseBody' "500": description: Internal Server Error schema: $ref: '#/definitions/schema.ResponseBody' summary: 清空公开对话的聊天记录 tags: - chat_public /api/v1/chat_public/{chat_id}/images: post: consumes: - application/json description: 将一个图片添加到聊天记录中 parameters: - in: path name: chat_id required: true type: integer - in: formData name: assistant_key required: true type: string - in: formData name: guest_id required: true type: string - in: formData name: url required: true type: string - description: 图片 in: formData name: image type: file produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/schema.ChatMessageResponse' type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' "404": description: Not Found schema: $ref: '#/definitions/schema.ResponseBody' "409": description: Conflict schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/schema.ChatMessageResponse' type: object "500": description: Internal Server Error schema: $ref: '#/definitions/schema.ResponseBody' summary: 添加图片 tags: - chat_public /api/v1/chat_public/{chat_id}/messages: get: consumes: - application/json parameters: - in: path name: chat_id required: true type: integer - in: query name: assistant_key required: true type: string - in: query name: guest_id required: true type: string produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: items: $ref: '#/definitions/entity.ChatMessage' type: array type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' summary: 获取公开对话的聊天记录 tags: - chat_public post: consumes: - application/json parameters: - in: path name: chat_id required: true type: integer - description: AddPublicChatMessageRequest in: body name: schema.AddPublicChatMessageRequest required: true schema: $ref: '#/definitions/schema.AddPublicChatMessageRequest' produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/schema.ChatMessageResponse' type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' "404": description: Not Found schema: $ref: '#/definitions/schema.ResponseBody' "409": description: Conflict schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/schema.ChatMessageResponse' type: object "500": description: Internal Server Error schema: $ref: '#/definitions/schema.ResponseBody' summary: 增加公开对话的聊天记录 tags: - chat_public /api/v1/chats: get: consumes: - application/json description: 列出当前账户下的所有的对话 parameters: - description: Assistant ID in: query name: assistant_id type: integer produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: items: $ref: '#/definitions/entity.Chat' type: array type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 获取所有 Chat tags: - chat post: consumes: - application/json description: 创建一个对话,如果不指定 Assistant ID,将会使用默认 Assistant。默认 Assistant 不支持上传文件以及使用外部工具。 parameters: - description: Chat in: body name: chat required: true schema: $ref: '#/definitions/schema.ChatCreateRequest' produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/entity.Chat' type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' "500": description: Internal Server Error schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: Create Chat tags: - chat /api/v1/chats/{id}: delete: consumes: - application/json description: 删除一个对话以及聊天记录 parameters: - description: Chat ID in: path name: id required: true type: integer produces: - application/json responses: "200": description: OK schema: $ref: '#/definitions/schema.ResponseBody' "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' "404": description: Not Found schema: $ref: '#/definitions/schema.ResponseBody' "500": description: Internal Server Error schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: Delete Chat tags: - chat get: consumes: - application/json description: 将返回一个实体 parameters: - in: path name: id required: true type: integer produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/entity.Chat' type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' "404": description: Not Found schema: $ref: '#/definitions/schema.ResponseBody' "500": description: Internal Server Error schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 显示一个对话的数据 tags: - chat put: consumes: - application/json description: 可以重新设置对话的一些信息 parameters: - in: path name: id required: true type: integer - description: ChatUpdateRequest in: body name: schema.ChatUpdateRequest required: true schema: $ref: '#/definitions/schema.ChatUpdateRequest' produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/entity.Chat' type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' "404": description: Not Found schema: $ref: '#/definitions/schema.ResponseBody' "500": description: Internal Server Error schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 更新对话 tags: - chat /api/v1/chats/{id}/clear: post: consumes: - application/json description: 清空当前聊天记录 parameters: - in: path name: id required: true type: integer produces: - application/json responses: "200": description: OK "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' "404": description: Not Found schema: $ref: '#/definitions/schema.ResponseBody' "409": description: Conflict schema: $ref: '#/definitions/schema.ResponseBody' "500": description: Internal Server Error schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 清空聊天记录 tags: - chat_message /api/v1/chats/{id}/files: post: consumes: - application/json description: 将一个文件添加到聊天记录中 parameters: - in: path name: id required: true type: integer - in: formData name: url required: true type: string - description: 文件 in: formData name: file type: file produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/schema.ChatMessageResponse' type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' "404": description: Not Found schema: $ref: '#/definitions/schema.ResponseBody' "409": description: Conflict schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/schema.ChatMessageResponse' type: object "500": description: Internal Server Error schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 添加文件 tags: - chat_message /api/v1/chats/{id}/messages: get: consumes: - application/json description: 获取一个对话的所有聊天记录 parameters: - in: path name: id required: true type: integer produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: items: $ref: '#/definitions/entity.ChatMessageList' type: array type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' "404": description: Not Found schema: $ref: '#/definitions/schema.ResponseBody' "500": description: Internal Server Error schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 查看聊天记录 tags: - chat_message post: consumes: - application/json description: 添加一条消息 parameters: - in: path name: id required: true type: integer - description: Message in: body name: message required: true schema: $ref: '#/definitions/schema.ChatMessageAddRequest' produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/schema.ChatMessageResponse' type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' "404": description: Not Found schema: $ref: '#/definitions/schema.ResponseBody' "409": description: Conflict schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/schema.ChatMessageResponse' type: object "500": description: Internal Server Error schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 添加聊天记录 tags: - chat_message /api/v1/files/download/{hash}: get: consumes: - application/json description: 根据文件 Hash 下载文件。仅支持图片下载,且图片具有有效期 parameters: - description: FileId uint64 `uri:"id" binding:"required"` in: path name: hash required: true type: string produces: - application/json responses: "200": description: OK schema: type: file summary: 下载图片 tags: - file /api/v1/libraries: get: consumes: - application/json produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: items: $ref: '#/definitions/entity.Library' type: array type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 获取所有的资料库 tags: - libraries post: consumes: - application/json parameters: - description: schema.LibraryCreateRequest in: body name: schema.LibraryCreateRequest required: true schema: $ref: '#/definitions/schema.LibraryCreateRequest' produces: - application/json responses: "201": description: Created schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/entity.Library' type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 创建一个资料库 tags: - libraries /api/v1/libraries/{id}: delete: consumes: - application/json parameters: - in: path name: id type: integer produces: - application/json responses: "204": description: No Content "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 删除资料库 tags: - libraries get: consumes: - application/json parameters: - in: path name: id type: integer produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: items: $ref: '#/definitions/entity.Library' type: array type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 获取一个资料库 tags: - libraries put: consumes: - application/json parameters: - in: path name: id type: integer - description: schema.LibraryUpdateRequest in: body name: schema.LibraryUpdateRequest required: true schema: $ref: '#/definitions/schema.LibraryUpdateRequest' produces: - application/json responses: "204": description: No Content "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 更新资料库 tags: - libraries /api/v1/libraries/{id}/documents: get: consumes: - application/json parameters: - in: path name: id type: integer produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: items: $ref: '#/definitions/entity.Document' type: array type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 列出资料库以及资料库下的文档 tags: - libraries post: consumes: - application/json parameters: - in: path name: id type: integer - description: schema.DocumentCreateRequest in: body name: schema.DocumentCreateRequest required: true schema: $ref: '#/definitions/schema.DocumentCreateRequest' produces: - application/json responses: "204": description: No Content "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 创建文档 tags: - libraries /api/v1/libraries/{id}/documents/{document_id}: delete: consumes: - application/json parameters: - in: path name: document_id type: integer - in: path name: id type: integer produces: - application/json responses: "204": description: No Content "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 删除指定的文档 tags: - libraries /api/v1/memories: get: consumes: - application/json produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: items: $ref: '#/definitions/entity.Memory' type: array type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 获取所有的记忆 tags: - memoires /api/v1/memories/{id}: delete: consumes: - application/json parameters: - in: path name: id required: true type: integer produces: - application/json responses: "204": description: No Content "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 删除指定的记忆 tags: - memoires /api/v1/memories/purge: post: consumes: - application/json produces: - application/json responses: "204": description: No Content "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 删除全部记忆 tags: - memoires /api/v1/ping: get: consumes: - application/json deprecated: true description: 测试接口,将会返回当前用户的信息 produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/schema.CurrentUserResponse' type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: Greet tags: - ping /api/v1/stream/{stream_id}: get: consumes: - application/json description: 将会通过 SSE 的方式来流式传输内容,不建议使用本文档生成的代码来获取,第三方库有更好的解决方案。 parameters: - description: 指定聊天中的用户 IP 地址,不指定则自动获取。此 IP 地址只会增加至 Prompt 中,如果不希望增加,请关闭系统自带 Prompt 选项 in: header name: X-User-IP type: string - in: path name: stream_id required: true type: string produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/schema.ChatMessageResponse' type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' "404": description: Not Found schema: $ref: '#/definitions/schema.ResponseBody' "409": description: Conflict schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/schema.ChatMessageResponse' type: object "500": description: Internal Server Error schema: $ref: '#/definitions/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/schema.ResponseBody' - properties: data: items: $ref: '#/definitions/entity.Tool' type: array type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: List Tool tags: - tool post: consumes: - application/json description: Create tool parameters: - description: Tool in: body name: tool required: true schema: $ref: '#/definitions/schema.ToolCreateRequest' produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/entity.Tool' type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] 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: integer produces: - application/json responses: "200": description: OK "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' "404": description: Not Found schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: DeleteTool tags: - tool get: consumes: - application/json description: Get tool parameters: - description: Tool ID in: path name: id required: true type: integer produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/entity.Tool' type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' "404": description: Not Found schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: Get Tool tags: - tool /api/v1/tools/{id}/update: post: consumes: - application/json description: 如果你的 Tool Discovery 内容改变了,你需要调用此接口更新数据 parameters: - description: Tool ID in: path name: id required: true type: integer produces: - application/json responses: "200": description: OK schema: allOf: - $ref: '#/definitions/schema.ResponseBody' - properties: data: $ref: '#/definitions/entity.Tool' type: object "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' "404": description: Not Found schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 更新 Tool 的数据 tags: - tool /api/v1/tools/syntax: post: consumes: - application/json description: 如果你的 Tool Discovery 内容改变了,你需要调用此接口更新数据 parameters: - description: ToolDiscoveryInput in: body name: toolDiscoveryInput required: true schema: $ref: '#/definitions/schema.ToolDiscoveryInput' produces: - application/json responses: "200": description: OK schema: $ref: '#/definitions/schema.ResponseBody' "400": description: Bad Request schema: $ref: '#/definitions/schema.ResponseBody' security: - ApiKeyAuth: [] summary: 校验 Discovery 语法 tags: - tool securityDefinitions: ApiKeyAuth: in: header name: Authorization type: apiKey swagger: "2.0"