1
0
forked from Leaf/amber-ui
amber-ui-re/api/swagger.yaml

2300 lines
56 KiB
YAML
Raw Normal View History

2024-09-10 08:29:08 +00:00
definitions:
entity.Assistant:
properties:
created_at:
type: string
description:
type: string
disable_default_prompt:
type: boolean
disable_memory:
type: boolean
2024-09-15 07:23:42 +00:00
enable_memory_for_assistant_api:
2024-09-10 08:29:08 +00:00
type: boolean
id:
description: Id schema.EntityId `gorm:"primarykey" json:"id,string"`
type: integer
library_id:
type: integer
name:
type: string
prompt:
type: string
updated_at:
type: string
user_id:
type: string
type: object
2024-09-15 07:23:42 +00:00
entity.AssistantKey:
2024-09-10 08:29:08 +00:00
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
2024-09-15 07:23:42 +00:00
secret:
2024-09-10 08:29:08 +00:00
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:
2024-09-16 05:37:23 +00:00
assistant:
$ref: '#/definitions/entity.Assistant'
2024-09-10 08:29:08 +00:00
assistant_id:
description: AssistantId 可以让同一个对话中,使用不同的助手来处理消息
type: integer
chat_id:
2024-09-10 08:29:08 +00:00
type: integer
completion_tokens:
type: integer
content:
type: string
created_at:
type: string
file:
$ref: '#/definitions/entity.File'
file_id:
2024-09-18 04:57:57 +00:00
description: FileId
2024-09-10 08:29:08 +00:00
type: integer
hidden:
2024-09-18 04:57:57 +00:00
description: |-
UserFileId *schema.EntityId `json:"user_file_id"`
UserFile *UserFile `json:"user_file"`
2024-09-10 08:29:08 +00:00
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
2024-09-16 05:37:23 +00:00
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:
2024-09-18 04:57:57 +00:00
description: |-
UserFileId *schema.EntityId `json:"user_file_id"`
UserFile *UserFile `json:"user_file"`
2024-09-16 05:37:23 +00:00
type: boolean
id:
type: integer
prompt_tokens:
type: integer
role:
type: string
total_tokens:
type: integer
updated_at:
type: string
type: object
2024-09-10 08:29:08 +00:00
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: |-
2024-09-18 04:57:57 +00:00
Public bool `json:"public"` // 是否公开,访客上传的文件应始终公开,或归属于所有者
2024-09-10 08:29:08 +00:00
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:
2024-09-15 07:23:42 +00:00
assistant_key:
2024-09-10 08:29:08 +00:00
type: string
guest_id:
type: string
message:
type: string
role:
enum:
- user
- user_hide
- system
- system_hide
- assistant
type: string
required:
2024-09-15 07:23:42 +00:00
- assistant_key
2024-09-10 08:29:08 +00:00
- 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
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
2024-09-15 07:23:42 +00:00
enable_memory_for_assistant_api:
2024-09-10 08:29:08 +00:00
enum:
- true
- false
type: boolean
library_id:
type: integer
2024-09-10 08:29:08 +00:00
name:
maxLength: 255
type: string
prompt:
maxLength: 512
type: string
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
2024-09-10 08:29:08 +00:00
message:
maxLength: 255
type: string
role:
enum:
- user
- user_hide
- system
- system_hide
- assistant
- image
type: string
2024-09-17 06:49:40 +00:00
variables:
additionalProperties:
type: string
type: object
2024-09-10 08:29:08 +00:00
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:
2024-09-15 07:23:42 +00:00
assistant_key:
2024-09-10 08:29:08 +00:00
type: string
guest_id:
type: string
name:
maxLength: 32
type: string
required:
2024-09-15 07:23:42 +00:00
- assistant_key
2024-09-10 08:29:08 +00:00
- 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
2024-09-10 08:29:08 +00:00
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
2024-09-10 08:29:08 +00:00
schema.FunctionsInput:
properties:
description:
type: string
name:
type: string
parameters:
$ref: '#/definitions/schema.ToolDiscoveryOutputFunctionParameters'
required:
- description
- name
- parameters
type: object
schema.GetPublicChatMessageRequest:
properties:
2024-09-15 07:23:42 +00:00
assistant_key:
2024-09-10 08:29:08 +00:00
type: string
guest_id:
type: string
required:
2024-09-15 07:23:42 +00:00
- assistant_key
2024-09-10 08:29:08 +00:00
- 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
2024-09-15 07:23:42 +00:00
discovery_url:
2024-09-10 08:29:08 +00:00
maxLength: 255
type: string
2024-09-15 07:23:42 +00:00
name:
2024-09-10 08:29:08 +00:00
maxLength: 255
type: string
required:
- description
2024-09-15 07:23:42 +00:00
- discovery_url
2024-09-10 08:29:08 +00:00
- 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:
2024-09-10 08:29:08 +00:00
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
2024-09-15 07:23:42 +00:00
/api/v1/assistants/{id}/keys:
get:
2024-09-10 08:29:08 +00:00
consumes:
- application/json
2024-09-15 07:23:42 +00:00
description: 此 API 可以创建一个 Assistant API Key可以将你的 Assistant 公开出去使用。
2024-09-10 08:29:08 +00:00
parameters:
- in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
2024-09-15 07:23:42 +00:00
"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
2024-09-10 08:29:08 +00:00
schema:
$ref: '#/definitions/schema.ResponseBody'
security:
- ApiKeyAuth: []
2024-09-15 07:23:42 +00:00
summary: 获取 Assistant API Key列表
2024-09-10 08:29:08 +00:00
tags:
- assistant
post:
consumes:
- application/json
2024-09-15 07:23:42 +00:00
description: 此方法将会获取一个 Token用户将会通过这个 Token 来访问你的 Assistant 并调用工具。
2024-09-10 08:29:08 +00:00
parameters:
- in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
2024-09-15 07:23:42 +00:00
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/schema.ResponseBody'
- properties:
data:
$ref: '#/definitions/entity.AssistantKey'
type: object
"500":
description: Internal Server Error
2024-09-10 08:29:08 +00:00
schema:
$ref: '#/definitions/schema.ResponseBody'
security:
- ApiKeyAuth: []
2024-09-15 07:23:42 +00:00
summary: 创建 Assistant API Key
2024-09-10 08:29:08 +00:00
tags:
- assistant
2024-09-15 07:23:42 +00:00
/api/v1/assistants/{id}/keys/{key_id}:
delete:
2024-09-10 08:29:08 +00:00
consumes:
- application/json
2024-09-15 07:23:42 +00:00
description: 此方法将会删除API Key删除后API Key将会立即失效。
2024-09-10 08:29:08 +00:00
parameters:
- in: path
name: id
required: true
type: integer
2024-09-15 07:23:42 +00:00
- in: path
name: key_id
required: true
type: integer
2024-09-10 08:29:08 +00:00
produces:
- application/json
responses:
"200":
description: OK
schema:
2024-09-15 07:23:42 +00:00
$ref: '#/definitions/schema.ResponseBody'
2024-09-10 08:29:08 +00:00
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/schema.ResponseBody'
security:
- ApiKeyAuth: []
2024-09-15 07:23:42 +00:00
summary: 删除 Assistant API Key
2024-09-10 08:29:08 +00:00
tags:
- assistant
2024-09-15 07:23:42 +00:00
/api/v1/assistants/{id}/library:
delete:
2024-09-10 08:29:08 +00:00
consumes:
- application/json
parameters:
- in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
2024-09-15 07:23:42 +00:00
"204":
description: No Content
"400":
description: Bad Request
2024-09-10 08:29:08 +00:00
schema:
$ref: '#/definitions/schema.ResponseBody'
security:
- ApiKeyAuth: []
2024-09-15 07:23:42 +00:00
summary: 解绑资料库
2024-09-10 08:29:08 +00:00
tags:
- assistant
2024-09-15 07:23:42 +00:00
post:
2024-09-10 08:29:08 +00:00
consumes:
- application/json
parameters:
- in: path
name: id
required: true
type: integer
2024-09-15 07:23:42 +00:00
- description: AssistantLibraryRequest
in: body
name: AssistantLibraryRequest
2024-09-10 08:29:08 +00:00
required: true
2024-09-15 07:23:42 +00:00
schema:
$ref: '#/definitions/schema.AssistantLibraryRequest'
2024-09-10 08:29:08 +00:00
produces:
- application/json
responses:
2024-09-15 07:23:42 +00:00
"204":
description: No Content
"400":
description: Bad Request
2024-09-10 08:29:08 +00:00
schema:
$ref: '#/definitions/schema.ResponseBody'
security:
- ApiKeyAuth: []
2024-09-15 07:23:42 +00:00
summary: 绑定资料库
2024-09-10 08:29:08 +00:00
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
2024-09-15 07:23:42 +00:00
name: assistant_key
2024-09-10 08:29:08 +00:00
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
2024-09-15 07:23:42 +00:00
name: assistant_key
2024-09-10 08:29:08 +00:00
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
2024-09-15 07:23:42 +00:00
description: 列出当前账户下的所有的对话
2024-09-10 08:29:08 +00:00
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
2024-09-15 07:23:42 +00:00
description: 创建一个对话,如果不指定 Assistant ID将会使用默认 Assistant。默认 Assistant 不支持上传文件以及使用外部工具。
2024-09-10 08:29:08 +00:00
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
2024-09-15 07:23:42 +00:00
description: 删除一个对话以及聊天记录
2024-09-10 08:29:08 +00:00
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
2024-09-10 08:29:08 +00:00
/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
2024-09-15 07:23:42 +00:00
description: 获取一个对话的所有聊天记录
2024-09-10 08:29:08 +00:00
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:
2024-09-16 05:37:23 +00:00
$ref: '#/definitions/entity.ChatMessageList'
2024-09-10 08:29:08 +00:00
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
2024-09-15 07:23:42 +00:00
description: 添加一条消息
2024-09-10 08:29:08 +00:00
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
2024-09-18 04:57:57 +00:00
/api/v1/files/download/{hash}:
2024-09-10 08:29:08 +00:00
get:
consumes:
- application/json
2024-09-18 04:57:57 +00:00
description: 根据文件 Hash 下载文件。仅支持图片下载,且图片具有有效期
2024-09-10 08:29:08 +00:00
parameters:
2024-09-18 04:57:57 +00:00
- description: FileId uint64 `uri:"id" binding:"required"`
in: path
name: hash
2024-09-10 08:29:08 +00:00
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
type: file
2024-09-18 04:57:57 +00:00
summary: 下载图片
2024-09-10 08:29:08 +00:00
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:
2024-09-10 08:29:08 +00:00
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
2024-09-10 08:29:08 +00:00
/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:
2024-09-16 13:58:56 +00:00
items:
$ref: '#/definitions/entity.Memory'
type: array
2024-09-10 08:29:08 +00:00
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
2024-09-15 07:23:42 +00:00
deprecated: true
description: 测试接口,将会返回当前用户的信息
2024-09-10 08:29:08 +00:00
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
2024-09-15 07:23:42 +00:00
description: 将会通过 SSE 的方式来流式传输内容,不建议使用本文档生成的代码来获取,第三方库有更好的解决方案。
2024-09-10 08:29:08 +00:00
parameters:
- description: 指定聊天中的用户 IP 地址,不指定则自动获取。此 IP 地址只会增加至 Prompt 中,如果不希望增加,请关闭系统自带
Prompt 选项
in: header
name: X-User-IP
type: string
2024-09-17 06:49:40 +00:00
- in: path
2024-09-10 08:29:08 +00:00
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: []
2024-09-15 07:23:42 +00:00
summary: 流式传输文本
2024-09-10 08:29:08 +00:00
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"