"代码更新:确保在flush=false时,重新加载时不会刷新新实体。此修复遵循指定的flush参数,以前新实体实例会刷新,现在只有在flush=true时才会刷新。"

This commit is contained in:
ivamp 2024-08-06 03:46:02 +08:00
parent 54bef3d8e5
commit 9b39c1a5e7
15 changed files with 4743 additions and 4320 deletions

View File

@ -16,6 +16,19 @@ definitions:
user_id:
type: integer
type: object
rag-new_internal_entity.AssistantShare:
properties:
assistant_id:
type: integer
created_at:
type: string
id:
type: integer
token:
type: string
updated_at:
type: string
type: object
rag-new_internal_entity.AssistantTool:
properties:
assistant_id:
@ -32,7 +45,7 @@ definitions:
rag-new_internal_entity.AssistantToolType:
properties:
assistant:
$ref: "#/definitions/rag-new_internal_entity.Assistant"
$ref: '#/definitions/rag-new_internal_entity.Assistant'
assistant_id:
type: integer
created_at:
@ -40,7 +53,7 @@ definitions:
id:
type: integer
tool:
$ref: "#/definitions/rag-new_internal_entity.Tool"
$ref: '#/definitions/rag-new_internal_entity.Tool'
tool_id:
type: integer
updated_at:
@ -52,10 +65,16 @@ definitions:
type: integer
created_at:
type: string
expired_at:
type: string
guest_id:
type: string
id:
type: integer
name:
type: string
owner:
type: string
updated_at:
type: string
user_id:
@ -89,7 +108,7 @@ definitions:
created_at:
type: string
data:
$ref: "#/definitions/rag-new_internal_schema.ToolDiscoveryOutput"
$ref: '#/definitions/rag-new_internal_schema.ToolDiscoveryOutput'
description:
type: string
discovery_url:
@ -103,6 +122,19 @@ definitions:
user_id:
type: integer
type: object
rag-new_internal_schema.AddPublicChatMessageRequest:
properties:
assistant_token:
type: string
guest_id:
type: string
message:
type: string
required:
- assistant_token
- guest_id
- message
type: object
rag-new_internal_schema.AssistantCreateRequest:
properties:
description:
@ -154,6 +186,27 @@ definitions:
stream_id:
type: string
type: object
rag-new_internal_schema.ChatPublicListRequest:
properties:
guest_id:
type: string
required:
- guest_id
type: object
rag-new_internal_schema.ChatPublicRequest:
properties:
assistant_token:
type: string
guest_id:
type: string
name:
maxLength: 32
type: string
required:
- assistant_token
- guest_id
- name
type: object
rag-new_internal_schema.CurrentUserResponse:
properties:
ip:
@ -167,6 +220,16 @@ definitions:
valid:
type: boolean
type: object
rag-new_internal_schema.GetPublicChatMessageRequest:
properties:
assistant_token:
type: string
guest_id:
type: string
required:
- assistant_token
- guest_id
type: object
rag-new_internal_schema.ResponseBody:
properties:
data: {}
@ -239,7 +302,7 @@ definitions:
type: string
function:
items:
$ref: "#/definitions/rag-new_internal_schema.ToolDiscoveryOutputFunctions"
$ref: '#/definitions/rag-new_internal_schema.ToolDiscoveryOutputFunctions'
type: array
homepage_url:
type: string
@ -262,7 +325,7 @@ definitions:
properties:
function:
items:
$ref: "#/definitions/rag-new_internal_schema.ToolDiscoveryOutputFunction"
$ref: '#/definitions/rag-new_internal_schema.ToolDiscoveryOutputFunction'
type: array
type:
type: string
@ -283,17 +346,17 @@ paths:
description: OK
schema:
allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody"
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
items:
$ref: "#/definitions/rag-new_internal_entity.Assistant"
$ref: '#/definitions/rag-new_internal_entity.Assistant'
type: array
type: object
"400":
description: Bad Request
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: 获取 Assistant 列表
@ -308,7 +371,7 @@ paths:
name: assistant
required: true
schema:
$ref: "#/definitions/rag-new_internal_schema.AssistantCreateRequest"
$ref: '#/definitions/rag-new_internal_schema.AssistantCreateRequest'
produces:
- application/json
responses:
@ -316,15 +379,15 @@ paths:
description: OK
schema:
allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody"
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
$ref: "#/definitions/rag-new_internal_entity.Assistant"
$ref: '#/definitions/rag-new_internal_entity.Assistant'
type: object
"400":
description: Bad Request
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: 创建 Assistant
@ -348,11 +411,11 @@ paths:
"404":
description: Not Found
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"500":
description: Internal Server Error
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: 删除 Assistant
@ -374,15 +437,15 @@ paths:
description: OK
schema:
allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody"
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
$ref: "#/definitions/rag-new_internal_entity.Assistant"
$ref: '#/definitions/rag-new_internal_entity.Assistant'
type: object
"400":
description: Bad Request
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: 获取指定的 Assistant
@ -402,7 +465,7 @@ paths:
name: assistantUpdateRequest
required: true
schema:
$ref: "#/definitions/rag-new_internal_schema.AssistantUpdateRequest"
$ref: '#/definitions/rag-new_internal_schema.AssistantUpdateRequest'
produces:
- application/json
responses:
@ -410,20 +473,113 @@ paths:
description: OK
schema:
allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody"
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
$ref: "#/definitions/rag-new_internal_entity.Assistant"
$ref: '#/definitions/rag-new_internal_entity.Assistant'
type: object
"400":
description: Bad Request
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: 更新 Assistant
tags:
- assistant
/api/v1/assistants/{id}/shares:
get:
consumes:
- application/json
description: 此 API 可以创建一个 Assistant 共享 Token可以将你的 Assistant 公开出去使用。
parameters:
- in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
items:
$ref: '#/definitions/rag-new_internal_entity.AssistantShare'
type: array
type: object
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: 获取 Assistant 共享列表
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/rag-new_internal_schema.ResponseBody'
- properties:
data:
$ref: '#/definitions/rag-new_internal_entity.AssistantShare'
type: object
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: 创建 Assistant 共享
tags:
- assistant
/api/v1/assistants/{id}/shares/{share_id}:
delete:
consumes:
- application/json
description: 此方法将会删除共享,删除后,共享将会立即失效。
parameters:
- in: path
name: id
required: true
type: integer
- in: path
name: share_id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: 删除 Assistant 共享
tags:
- assistant
/api/v1/assistants/{id}/tools:
get:
consumes:
@ -441,17 +597,17 @@ paths:
description: OK
schema:
allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody"
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
items:
$ref: "#/definitions/rag-new_internal_entity.AssistantToolType"
$ref: '#/definitions/rag-new_internal_entity.AssistantToolType'
type: array
type: object
"500":
description: Internal Server Error
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: 获取 Assistant 所绑定的 Tool
@ -479,15 +635,15 @@ paths:
description: OK
schema:
allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody"
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
$ref: "#/definitions/rag-new_internal_entity.AssistantTool"
$ref: '#/definitions/rag-new_internal_entity.AssistantTool'
type: object
"500":
description: Internal Server Error
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: 解绑 Tool
@ -514,20 +670,204 @@ paths:
description: OK
schema:
allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody"
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
$ref: "#/definitions/rag-new_internal_entity.AssistantTool"
$ref: '#/definitions/rag-new_internal_entity.AssistantTool'
type: object
"500":
description: Internal Server Error
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_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/rag-new_internal_schema.ChatPublicListRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
items:
$ref: '#/definitions/rag-new_internal_entity.Chat'
type: array
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
summary: 获取公开对话
tags:
- chat_public
post:
consumes:
- application/json
parameters:
- description: ChatPublicRequest
in: body
name: schema.ChatPublicRequest
required: true
schema:
$ref: '#/definitions/rag-new_internal_schema.ChatPublicRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
$ref: '#/definitions/rag-new_internal_entity.Chat'
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
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/rag-new_internal_schema.GetPublicChatMessageRequest'
produces:
- application/json
responses:
"200":
description: OK
"400":
description: Bad Request
schema:
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"404":
description: Not Found
schema:
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/rag-new_internal_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_token
required: true
type: string
- in: query
name: guest_id
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
items:
$ref: '#/definitions/rag-new_internal_entity.ChatMessage'
type: array
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
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/rag-new_internal_schema.AddPublicChatMessageRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
$ref: '#/definitions/rag-new_internal_schema.ChatMessageResponse'
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"404":
description: Not Found
schema:
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"409":
description: Conflict
schema:
allOf:
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
$ref: '#/definitions/rag-new_internal_schema.ChatMessageResponse'
type: object
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
summary: 增加公开对话的聊天记录
tags:
- chat_public
/api/v1/chats:
get:
consumes:
@ -545,17 +885,17 @@ paths:
description: OK
schema:
allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody"
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
items:
$ref: "#/definitions/rag-new_internal_entity.Chat"
$ref: '#/definitions/rag-new_internal_entity.Chat'
type: array
type: object
"400":
description: Bad Request
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: 获取所有 Chat
@ -571,7 +911,7 @@ paths:
name: chat
required: true
schema:
$ref: "#/definitions/rag-new_internal_schema.ChatCreateRequest"
$ref: '#/definitions/rag-new_internal_schema.ChatCreateRequest'
produces:
- application/json
responses:
@ -579,19 +919,19 @@ paths:
description: OK
schema:
allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody"
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
$ref: "#/definitions/rag-new_internal_entity.Chat"
$ref: '#/definitions/rag-new_internal_entity.Chat'
type: object
"400":
description: Bad Request
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"500":
description: Internal Server Error
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: Create Chat
@ -614,19 +954,19 @@ paths:
"200":
description: OK
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"400":
description: Bad Request
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"404":
description: Not Found
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"500":
description: Internal Server Error
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: Delete Chat
@ -651,19 +991,19 @@ paths:
"400":
description: Bad Request
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"404":
description: Not Found
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"409":
description: Conflict
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"500":
description: Internal Server Error
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: 清空聊天记录
@ -687,25 +1027,25 @@ paths:
description: OK
schema:
allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody"
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
items:
$ref: "#/definitions/rag-new_internal_entity.ChatMessage"
$ref: '#/definitions/rag-new_internal_entity.ChatMessage'
type: array
type: object
"400":
description: Bad Request
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"404":
description: Not Found
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"500":
description: Internal Server Error
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: 查看聊天记录
@ -726,7 +1066,7 @@ paths:
name: message
required: true
schema:
$ref: "#/definitions/rag-new_internal_schema.ChatMessageAddRequest"
$ref: '#/definitions/rag-new_internal_schema.ChatMessageAddRequest'
produces:
- application/json
responses:
@ -734,32 +1074,32 @@ paths:
description: OK
schema:
allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody"
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
$ref: "#/definitions/rag-new_internal_schema.ChatMessageResponse"
$ref: '#/definitions/rag-new_internal_schema.ChatMessageResponse'
type: object
"400":
description: Bad Request
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"404":
description: Not Found
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"409":
description: Conflict
schema:
allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody"
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
$ref: "#/definitions/rag-new_internal_schema.ChatMessageResponse"
$ref: '#/definitions/rag-new_internal_schema.ChatMessageResponse'
type: object
"500":
description: Internal Server Error
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: 添加聊天记录
@ -777,15 +1117,15 @@ paths:
description: OK
schema:
allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody"
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
$ref: "#/definitions/rag-new_internal_schema.CurrentUserResponse"
$ref: '#/definitions/rag-new_internal_schema.CurrentUserResponse'
type: object
"400":
description: Bad Request
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: Greet
@ -814,32 +1154,32 @@ paths:
description: OK
schema:
allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody"
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
$ref: "#/definitions/rag-new_internal_schema.ChatMessageResponse"
$ref: '#/definitions/rag-new_internal_schema.ChatMessageResponse'
type: object
"400":
description: Bad Request
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"404":
description: Not Found
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"409":
description: Conflict
schema:
allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody"
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
$ref: "#/definitions/rag-new_internal_schema.ChatMessageResponse"
$ref: '#/definitions/rag-new_internal_schema.ChatMessageResponse'
type: object
"500":
description: Internal Server Error
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- none: []
summary: 流式传输聊天内容
@ -857,17 +1197,17 @@ paths:
description: OK
schema:
allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody"
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
items:
$ref: "#/definitions/rag-new_internal_entity.Tool"
$ref: '#/definitions/rag-new_internal_entity.Tool'
type: array
type: object
"400":
description: Bad Request
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: List Tool
@ -883,7 +1223,7 @@ paths:
name: tool
required: true
schema:
$ref: "#/definitions/rag-new_internal_schema.ToolCreateRequest"
$ref: '#/definitions/rag-new_internal_schema.ToolCreateRequest'
produces:
- application/json
responses:
@ -891,15 +1231,15 @@ paths:
description: OK
schema:
allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody"
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
$ref: "#/definitions/rag-new_internal_entity.Tool"
$ref: '#/definitions/rag-new_internal_entity.Tool'
type: object
"400":
description: Bad Request
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: Create Tool
@ -924,11 +1264,11 @@ paths:
"400":
description: Bad Request
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"404":
description: Not Found
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: DeleteTool
@ -951,19 +1291,19 @@ paths:
description: OK
schema:
allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody"
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
$ref: "#/definitions/rag-new_internal_entity.Tool"
$ref: '#/definitions/rag-new_internal_entity.Tool'
type: object
"400":
description: Bad Request
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"404":
description: Not Found
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: Get Tool
@ -987,19 +1327,19 @@ paths:
description: OK
schema:
allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody"
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties:
data:
$ref: "#/definitions/rag-new_internal_entity.Tool"
$ref: '#/definitions/rag-new_internal_entity.Tool'
type: object
"400":
description: Bad Request
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"404":
description: Not Found
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: 更新 Tool 的数据
@ -1016,18 +1356,18 @@ paths:
name: toolDiscoveryInput
required: true
schema:
$ref: "#/definitions/rag-new_internal_schema.ToolDiscoveryInput"
$ref: '#/definitions/rag-new_internal_schema.ToolDiscoveryInput'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"400":
description: Bad Request
schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody"
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: 校验 Discovery 语法

File diff suppressed because it is too large Load Diff

View File

@ -12,11 +12,12 @@
* Do not edit the class manually.
*/
import type { Configuration } from "./configuration";
import type { Configuration } from './configuration';
// Some imports not used depending on template conditions
// @ts-ignore
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from "axios";
import globalAxios from "axios";
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
export const BASE_PATH = "http://localhost".replace(/\/+$/, "");
@ -49,17 +50,13 @@ export interface RequestArgs {
export class BaseAPI {
protected configuration: Configuration | undefined;
constructor(
configuration?: Configuration,
protected basePath: string = BASE_PATH,
protected axios: AxiosInstance = globalAxios,
) {
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
if (configuration) {
this.configuration = configuration;
this.basePath = configuration.basePath ?? basePath;
}
}
}
};
/**
*
@ -68,19 +65,16 @@ export class BaseAPI {
* @extends {Error}
*/
export class RequiredError extends Error {
constructor(
public field: string,
msg?: string,
) {
constructor(public field: string, msg?: string) {
super(msg);
this.name = "RequiredError";
this.name = "RequiredError"
}
}
interface ServerMap {
[key: string]: {
url: string;
description: string;
url: string,
description: string,
}[];
}
@ -88,4 +82,5 @@ interface ServerMap {
*
* @export
*/
export const operationServerMap: ServerMap = {};
export const operationServerMap: ServerMap = {
}

View File

@ -12,129 +12,95 @@
* Do not edit the class manually.
*/
import type { Configuration } from "./configuration";
import type { RequestArgs } from "./base";
import type { AxiosInstance, AxiosResponse } from "axios";
import type { AxiosInstance, AxiosResponse } from 'axios';
import { RequiredError } from "./base";
/**
*
* @export
*/
export const DUMMY_BASE_URL = "https://example.com";
export const DUMMY_BASE_URL = 'https://example.com'
/**
*
* @throws {RequiredError}
* @export
*/
export const assertParamExists = function (
functionName: string,
paramName: string,
paramValue: unknown,
) {
export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
if (paramValue === null || paramValue === undefined) {
throw new RequiredError(
paramName,
`Required parameter ${paramName} was null or undefined when calling ${functionName}.`,
);
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
}
};
}
/**
*
* @export
*/
export const setApiKeyToObject = async function (
object: any,
keyParamName: string,
configuration?: Configuration,
) {
export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
if (configuration && configuration.apiKey) {
const localVarApiKeyValue =
typeof configuration.apiKey === "function"
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
? await configuration.apiKey(keyParamName)
: await configuration.apiKey;
object[keyParamName] = localVarApiKeyValue;
}
};
}
/**
*
* @export
*/
export const setBasicAuthToObject = function (
object: any,
configuration?: Configuration,
) {
export const setBasicAuthToObject = function (object: any, configuration?: Configuration) {
if (configuration && (configuration.username || configuration.password)) {
object["auth"] = {
username: configuration.username,
password: configuration.password,
};
object["auth"] = { username: configuration.username, password: configuration.password };
}
};
}
/**
*
* @export
*/
export const setBearerAuthToObject = async function (
object: any,
configuration?: Configuration,
) {
export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
if (configuration && configuration.accessToken) {
const accessToken =
typeof configuration.accessToken === "function"
const accessToken = typeof configuration.accessToken === 'function'
? await configuration.accessToken()
: await configuration.accessToken;
object["Authorization"] = "Bearer " + accessToken;
}
};
}
/**
*
* @export
*/
export const setOAuthToObject = async function (
object: any,
name: string,
scopes: string[],
configuration?: Configuration,
) {
export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) {
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue =
typeof configuration.accessToken === "function"
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? await configuration.accessToken(name, scopes)
: await configuration.accessToken;
object["Authorization"] = "Bearer " + localVarAccessTokenValue;
}
};
}
function setFlattenedQueryParams(
urlSearchParams: URLSearchParams,
parameter: any,
key: string = "",
): void {
function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void {
if (parameter == null) return;
if (typeof parameter === "object") {
if (Array.isArray(parameter)) {
(parameter as any[]).forEach((item) =>
setFlattenedQueryParams(urlSearchParams, item, key),
);
} else {
Object.keys(parameter).forEach((currentKey) =>
setFlattenedQueryParams(
urlSearchParams,
parameter[currentKey],
`${key}${key !== "" ? "." : ""}${currentKey}`,
),
(parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
}
else {
Object.keys(parameter).forEach(currentKey =>
setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`)
);
}
} else {
}
else {
if (urlSearchParams.has(key)) {
urlSearchParams.append(key, parameter);
} else {
}
else {
urlSearchParams.set(key, parameter);
}
}
@ -148,55 +114,37 @@ export const setSearchParams = function (url: URL, ...objects: any[]) {
const searchParams = new URLSearchParams(url.search);
setFlattenedQueryParams(searchParams, objects);
url.search = searchParams.toString();
};
}
/**
*
* @export
*/
export const serializeDataIfNeeded = function (
value: any,
requestOptions: any,
configuration?: Configuration,
) {
const nonString = typeof value !== "string";
const needsSerialization =
nonString && configuration && configuration.isJsonMime
? configuration.isJsonMime(requestOptions.headers["Content-Type"])
export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
const nonString = typeof value !== 'string';
const needsSerialization = nonString && configuration && configuration.isJsonMime
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
: nonString;
return needsSerialization
? JSON.stringify(value !== undefined ? value : {})
: value || "";
};
: (value || "");
}
/**
*
* @export
*/
export const toPathString = function (url: URL) {
return url.pathname + url.search + url.hash;
};
return url.pathname + url.search + url.hash
}
/**
*
* @export
*/
export const createRequestFunction = function (
axiosArgs: RequestArgs,
globalAxios: AxiosInstance,
BASE_PATH: string,
configuration?: Configuration,
) {
return <T = unknown, R = AxiosResponse<T>>(
axios: AxiosInstance = globalAxios,
basePath: string = BASE_PATH,
) => {
const axiosRequestArgs = {
...axiosArgs.options,
url:
(axios.defaults.baseURL ? "" : (configuration?.basePath ?? basePath)) +
axiosArgs.url,
};
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url};
return axios.request<T, R>(axiosRequestArgs);
};
};
}

View File

@ -12,19 +12,12 @@
* Do not edit the class manually.
*/
export interface ConfigurationParameters {
apiKey?:
| string
| Promise<string>
| ((name: string) => string)
| ((name: string) => Promise<string>);
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
username?: string;
password?: string;
accessToken?:
| string
| Promise<string>
| ((name?: string, scopes?: string[]) => string)
| ((name?: string, scopes?: string[]) => Promise<string>);
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
basePath?: string;
serverIndex?: number;
baseOptions?: any;
@ -37,11 +30,7 @@ export class Configuration {
* @param name security name
* @memberof Configuration
*/
apiKey?:
| string
| Promise<string>
| ((name: string) => string)
| ((name: string) => Promise<string>);
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
/**
* parameter for basic security
*
@ -62,11 +51,7 @@ export class Configuration {
* @param scopes oauth2 scope
* @memberof Configuration
*/
accessToken?:
| string
| Promise<string>
| ((name?: string, scopes?: string[]) => string)
| ((name?: string, scopes?: string[]) => Promise<string>);
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
/**
* override base path
*
@ -119,14 +104,7 @@ export class Configuration {
* @return True if the given MIME is JSON, false otherwise.
*/
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp(
"^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$",
"i",
);
return (
mime !== null &&
(jsonMime.test(mime) ||
mime.toLowerCase() === "application/json-patch+json")
);
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
}
}

View File

@ -12,5 +12,7 @@
* Do not edit the class manually.
*/
export * from "./api";
export * from "./configuration";

424
src/auto-imports.d.ts vendored
View File

@ -5,271 +5,187 @@
// Generated by unplugin-auto-import
export {}
declare global {
const EffectScope: (typeof import("vue"))["EffectScope"];
const computed: (typeof import("vue"))["computed"];
const createApp: (typeof import("vue"))["createApp"];
const customRef: (typeof import("vue"))["customRef"];
const defineAsyncComponent: (typeof import("vue"))["defineAsyncComponent"];
const defineComponent: (typeof import("vue"))["defineComponent"];
const effectScope: (typeof import("vue"))["effectScope"];
const getCurrentInstance: (typeof import("vue"))["getCurrentInstance"];
const getCurrentScope: (typeof import("vue"))["getCurrentScope"];
const h: (typeof import("vue"))["h"];
const inject: (typeof import("vue"))["inject"];
const isProxy: (typeof import("vue"))["isProxy"];
const isReactive: (typeof import("vue"))["isReactive"];
const isReadonly: (typeof import("vue"))["isReadonly"];
const isRef: (typeof import("vue"))["isRef"];
const markRaw: (typeof import("vue"))["markRaw"];
const nextTick: (typeof import("vue"))["nextTick"];
const onActivated: (typeof import("vue"))["onActivated"];
const onBeforeMount: (typeof import("vue"))["onBeforeMount"];
const onBeforeRouteLeave: (typeof import("vue-router"))["onBeforeRouteLeave"];
const onBeforeRouteUpdate: (typeof import("vue-router"))["onBeforeRouteUpdate"];
const onBeforeUnmount: (typeof import("vue"))["onBeforeUnmount"];
const onBeforeUpdate: (typeof import("vue"))["onBeforeUpdate"];
const onDeactivated: (typeof import("vue"))["onDeactivated"];
const onErrorCaptured: (typeof import("vue"))["onErrorCaptured"];
const onMounted: (typeof import("vue"))["onMounted"];
const onRenderTracked: (typeof import("vue"))["onRenderTracked"];
const onRenderTriggered: (typeof import("vue"))["onRenderTriggered"];
const onScopeDispose: (typeof import("vue"))["onScopeDispose"];
const onServerPrefetch: (typeof import("vue"))["onServerPrefetch"];
const onUnmounted: (typeof import("vue"))["onUnmounted"];
const onUpdated: (typeof import("vue"))["onUpdated"];
const provide: (typeof import("vue"))["provide"];
const reactive: (typeof import("vue"))["reactive"];
const readonly: (typeof import("vue"))["readonly"];
const ref: (typeof import("vue"))["ref"];
const resolveComponent: (typeof import("vue"))["resolveComponent"];
const shallowReactive: (typeof import("vue"))["shallowReactive"];
const shallowReadonly: (typeof import("vue"))["shallowReadonly"];
const shallowRef: (typeof import("vue"))["shallowRef"];
const toRaw: (typeof import("vue"))["toRaw"];
const toRef: (typeof import("vue"))["toRef"];
const toRefs: (typeof import("vue"))["toRefs"];
const toValue: (typeof import("vue"))["toValue"];
const triggerRef: (typeof import("vue"))["triggerRef"];
const unref: (typeof import("vue"))["unref"];
const useAttrs: (typeof import("vue"))["useAttrs"];
const useCssModule: (typeof import("vue"))["useCssModule"];
const useCssVars: (typeof import("vue"))["useCssVars"];
const useLink: (typeof import("vue-router"))["useLink"];
const useRoute: (typeof import("vue-router/auto"))["useRoute"];
const useRouter: (typeof import("vue-router/auto"))["useRouter"];
const useSlots: (typeof import("vue"))["useSlots"];
const watch: (typeof import("vue"))["watch"];
const watchEffect: (typeof import("vue"))["watchEffect"];
const watchPostEffect: (typeof import("vue"))["watchPostEffect"];
const watchSyncEffect: (typeof import("vue"))["watchSyncEffect"];
const EffectScope: typeof import('vue')['EffectScope']
const computed: typeof import('vue')['computed']
const createApp: typeof import('vue')['createApp']
const customRef: typeof import('vue')['customRef']
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
const defineComponent: typeof import('vue')['defineComponent']
const effectScope: typeof import('vue')['effectScope']
const getCurrentInstance: typeof import('vue')['getCurrentInstance']
const getCurrentScope: typeof import('vue')['getCurrentScope']
const h: typeof import('vue')['h']
const inject: typeof import('vue')['inject']
const isProxy: typeof import('vue')['isProxy']
const isReactive: typeof import('vue')['isReactive']
const isReadonly: typeof import('vue')['isReadonly']
const isRef: typeof import('vue')['isRef']
const markRaw: typeof import('vue')['markRaw']
const nextTick: typeof import('vue')['nextTick']
const onActivated: typeof import('vue')['onActivated']
const onBeforeMount: typeof import('vue')['onBeforeMount']
const onBeforeRouteLeave: (typeof import("vue-router"))["onBeforeRouteLeave"]
const onBeforeRouteUpdate: (typeof import("vue-router"))["onBeforeRouteUpdate"]
const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']
const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
const onDeactivated: typeof import('vue')['onDeactivated']
const onErrorCaptured: typeof import('vue')['onErrorCaptured']
const onMounted: typeof import('vue')['onMounted']
const onRenderTracked: typeof import('vue')['onRenderTracked']
const onRenderTriggered: typeof import('vue')['onRenderTriggered']
const onScopeDispose: typeof import('vue')['onScopeDispose']
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
const onUnmounted: typeof import('vue')['onUnmounted']
const onUpdated: typeof import('vue')['onUpdated']
const provide: typeof import('vue')['provide']
const reactive: typeof import('vue')['reactive']
const readonly: typeof import('vue')['readonly']
const ref: typeof import('vue')['ref']
const resolveComponent: typeof import('vue')['resolveComponent']
const shallowReactive: typeof import('vue')['shallowReactive']
const shallowReadonly: typeof import('vue')['shallowReadonly']
const shallowRef: typeof import('vue')['shallowRef']
const toRaw: typeof import('vue')['toRaw']
const toRef: typeof import('vue')['toRef']
const toRefs: typeof import('vue')['toRefs']
const toValue: typeof import('vue')['toValue']
const triggerRef: typeof import('vue')['triggerRef']
const unref: typeof import('vue')['unref']
const useAttrs: typeof import('vue')['useAttrs']
const useCssModule: typeof import('vue')['useCssModule']
const useCssVars: typeof import('vue')['useCssVars']
const useLink: (typeof import("vue-router"))["useLink"]
const useRoute: typeof import('vue-router/auto')['useRoute']
const useRouter: typeof import('vue-router/auto')['useRouter']
const useSlots: typeof import('vue')['useSlots']
const watch: typeof import('vue')['watch']
const watchEffect: typeof import('vue')['watchEffect']
const watchPostEffect: typeof import('vue')['watchPostEffect']
const watchSyncEffect: typeof import('vue')['watchSyncEffect']
}
// for type re-export
declare global {
// @ts-ignore
export type {
Component,
ComponentPublicInstance,
ComputedRef,
ExtractDefaultPropTypes,
ExtractPropTypes,
ExtractPublicPropTypes,
InjectionKey,
PropType,
Ref,
VNode,
WritableComputedRef,
} from "vue";
import("vue");
export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue'
import('vue')
}
// for vue template auto import
import { UnwrapRef } from "vue";
declare module "vue" {
import { UnwrapRef } from 'vue'
declare module 'vue' {
interface GlobalComponents {}
interface ComponentCustomProperties {
readonly EffectScope: UnwrapRef<(typeof import("vue"))["EffectScope"]>;
readonly computed: UnwrapRef<(typeof import("vue"))["computed"]>;
readonly createApp: UnwrapRef<(typeof import("vue"))["createApp"]>;
readonly customRef: UnwrapRef<(typeof import("vue"))["customRef"]>;
readonly defineAsyncComponent: UnwrapRef<
(typeof import("vue"))["defineAsyncComponent"]
>;
readonly defineComponent: UnwrapRef<
(typeof import("vue"))["defineComponent"]
>;
readonly effectScope: UnwrapRef<(typeof import("vue"))["effectScope"]>;
readonly getCurrentInstance: UnwrapRef<
(typeof import("vue"))["getCurrentInstance"]
>;
readonly getCurrentScope: UnwrapRef<
(typeof import("vue"))["getCurrentScope"]
>;
readonly h: UnwrapRef<(typeof import("vue"))["h"]>;
readonly inject: UnwrapRef<(typeof import("vue"))["inject"]>;
readonly isProxy: UnwrapRef<(typeof import("vue"))["isProxy"]>;
readonly isReactive: UnwrapRef<(typeof import("vue"))["isReactive"]>;
readonly isReadonly: UnwrapRef<(typeof import("vue"))["isReadonly"]>;
readonly isRef: UnwrapRef<(typeof import("vue"))["isRef"]>;
readonly markRaw: UnwrapRef<(typeof import("vue"))["markRaw"]>;
readonly nextTick: UnwrapRef<(typeof import("vue"))["nextTick"]>;
readonly onActivated: UnwrapRef<(typeof import("vue"))["onActivated"]>;
readonly onBeforeMount: UnwrapRef<(typeof import("vue"))["onBeforeMount"]>;
readonly onBeforeUnmount: UnwrapRef<
(typeof import("vue"))["onBeforeUnmount"]
>;
readonly onBeforeUpdate: UnwrapRef<
(typeof import("vue"))["onBeforeUpdate"]
>;
readonly onDeactivated: UnwrapRef<(typeof import("vue"))["onDeactivated"]>;
readonly onErrorCaptured: UnwrapRef<
(typeof import("vue"))["onErrorCaptured"]
>;
readonly onMounted: UnwrapRef<(typeof import("vue"))["onMounted"]>;
readonly onRenderTracked: UnwrapRef<
(typeof import("vue"))["onRenderTracked"]
>;
readonly onRenderTriggered: UnwrapRef<
(typeof import("vue"))["onRenderTriggered"]
>;
readonly onScopeDispose: UnwrapRef<
(typeof import("vue"))["onScopeDispose"]
>;
readonly onServerPrefetch: UnwrapRef<
(typeof import("vue"))["onServerPrefetch"]
>;
readonly onUnmounted: UnwrapRef<(typeof import("vue"))["onUnmounted"]>;
readonly onUpdated: UnwrapRef<(typeof import("vue"))["onUpdated"]>;
readonly provide: UnwrapRef<(typeof import("vue"))["provide"]>;
readonly reactive: UnwrapRef<(typeof import("vue"))["reactive"]>;
readonly readonly: UnwrapRef<(typeof import("vue"))["readonly"]>;
readonly ref: UnwrapRef<(typeof import("vue"))["ref"]>;
readonly resolveComponent: UnwrapRef<
(typeof import("vue"))["resolveComponent"]
>;
readonly shallowReactive: UnwrapRef<
(typeof import("vue"))["shallowReactive"]
>;
readonly shallowReadonly: UnwrapRef<
(typeof import("vue"))["shallowReadonly"]
>;
readonly shallowRef: UnwrapRef<(typeof import("vue"))["shallowRef"]>;
readonly toRaw: UnwrapRef<(typeof import("vue"))["toRaw"]>;
readonly toRef: UnwrapRef<(typeof import("vue"))["toRef"]>;
readonly toRefs: UnwrapRef<(typeof import("vue"))["toRefs"]>;
readonly toValue: UnwrapRef<(typeof import("vue"))["toValue"]>;
readonly triggerRef: UnwrapRef<(typeof import("vue"))["triggerRef"]>;
readonly unref: UnwrapRef<(typeof import("vue"))["unref"]>;
readonly useAttrs: UnwrapRef<(typeof import("vue"))["useAttrs"]>;
readonly useCssModule: UnwrapRef<(typeof import("vue"))["useCssModule"]>;
readonly useCssVars: UnwrapRef<(typeof import("vue"))["useCssVars"]>;
readonly useRoute: UnwrapRef<
(typeof import("vue-router/auto"))["useRoute"]
>;
readonly useRouter: UnwrapRef<
(typeof import("vue-router/auto"))["useRouter"]
>;
readonly useSlots: UnwrapRef<(typeof import("vue"))["useSlots"]>;
readonly watch: UnwrapRef<(typeof import("vue"))["watch"]>;
readonly watchEffect: UnwrapRef<(typeof import("vue"))["watchEffect"]>;
readonly watchPostEffect: UnwrapRef<
(typeof import("vue"))["watchPostEffect"]
>;
readonly watchSyncEffect: UnwrapRef<
(typeof import("vue"))["watchSyncEffect"]
>;
readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
readonly computed: UnwrapRef<typeof import('vue')['computed']>
readonly createApp: UnwrapRef<typeof import('vue')['createApp']>
readonly customRef: UnwrapRef<typeof import('vue')['customRef']>
readonly defineAsyncComponent: UnwrapRef<typeof import('vue')['defineAsyncComponent']>
readonly defineComponent: UnwrapRef<typeof import('vue')['defineComponent']>
readonly effectScope: UnwrapRef<typeof import('vue')['effectScope']>
readonly getCurrentInstance: UnwrapRef<typeof import('vue')['getCurrentInstance']>
readonly getCurrentScope: UnwrapRef<typeof import('vue')['getCurrentScope']>
readonly h: UnwrapRef<typeof import('vue')['h']>
readonly inject: UnwrapRef<typeof import('vue')['inject']>
readonly isProxy: UnwrapRef<typeof import('vue')['isProxy']>
readonly isReactive: UnwrapRef<typeof import('vue')['isReactive']>
readonly isReadonly: UnwrapRef<typeof import('vue')['isReadonly']>
readonly isRef: UnwrapRef<typeof import('vue')['isRef']>
readonly markRaw: UnwrapRef<typeof import('vue')['markRaw']>
readonly nextTick: UnwrapRef<typeof import('vue')['nextTick']>
readonly onActivated: UnwrapRef<typeof import('vue')['onActivated']>
readonly onBeforeMount: UnwrapRef<typeof import('vue')['onBeforeMount']>
readonly onBeforeUnmount: UnwrapRef<typeof import('vue')['onBeforeUnmount']>
readonly onBeforeUpdate: UnwrapRef<typeof import('vue')['onBeforeUpdate']>
readonly onDeactivated: UnwrapRef<typeof import('vue')['onDeactivated']>
readonly onErrorCaptured: UnwrapRef<typeof import('vue')['onErrorCaptured']>
readonly onMounted: UnwrapRef<typeof import('vue')['onMounted']>
readonly onRenderTracked: UnwrapRef<typeof import('vue')['onRenderTracked']>
readonly onRenderTriggered: UnwrapRef<typeof import('vue')['onRenderTriggered']>
readonly onScopeDispose: UnwrapRef<typeof import('vue')['onScopeDispose']>
readonly onServerPrefetch: UnwrapRef<typeof import('vue')['onServerPrefetch']>
readonly onUnmounted: UnwrapRef<typeof import('vue')['onUnmounted']>
readonly onUpdated: UnwrapRef<typeof import('vue')['onUpdated']>
readonly provide: UnwrapRef<typeof import('vue')['provide']>
readonly reactive: UnwrapRef<typeof import('vue')['reactive']>
readonly readonly: UnwrapRef<typeof import('vue')['readonly']>
readonly ref: UnwrapRef<typeof import('vue')['ref']>
readonly resolveComponent: UnwrapRef<typeof import('vue')['resolveComponent']>
readonly shallowReactive: UnwrapRef<typeof import('vue')['shallowReactive']>
readonly shallowReadonly: UnwrapRef<typeof import('vue')['shallowReadonly']>
readonly shallowRef: UnwrapRef<typeof import('vue')['shallowRef']>
readonly toRaw: UnwrapRef<typeof import('vue')['toRaw']>
readonly toRef: UnwrapRef<typeof import('vue')['toRef']>
readonly toRefs: UnwrapRef<typeof import('vue')['toRefs']>
readonly toValue: UnwrapRef<typeof import('vue')['toValue']>
readonly triggerRef: UnwrapRef<typeof import('vue')['triggerRef']>
readonly unref: UnwrapRef<typeof import('vue')['unref']>
readonly useAttrs: UnwrapRef<typeof import('vue')['useAttrs']>
readonly useCssModule: UnwrapRef<typeof import('vue')['useCssModule']>
readonly useCssVars: UnwrapRef<typeof import('vue')['useCssVars']>
readonly useRoute: UnwrapRef<typeof import('vue-router/auto')['useRoute']>
readonly useRouter: UnwrapRef<typeof import('vue-router/auto')['useRouter']>
readonly useSlots: UnwrapRef<typeof import('vue')['useSlots']>
readonly watch: UnwrapRef<typeof import('vue')['watch']>
readonly watchEffect: UnwrapRef<typeof import('vue')['watchEffect']>
readonly watchPostEffect: UnwrapRef<typeof import('vue')['watchPostEffect']>
readonly watchSyncEffect: UnwrapRef<typeof import('vue')['watchSyncEffect']>
}
}
declare module "@vue/runtime-core" {
declare module '@vue/runtime-core' {
interface GlobalComponents {}
interface ComponentCustomProperties {
readonly EffectScope: UnwrapRef<(typeof import("vue"))["EffectScope"]>;
readonly computed: UnwrapRef<(typeof import("vue"))["computed"]>;
readonly createApp: UnwrapRef<(typeof import("vue"))["createApp"]>;
readonly customRef: UnwrapRef<(typeof import("vue"))["customRef"]>;
readonly defineAsyncComponent: UnwrapRef<
(typeof import("vue"))["defineAsyncComponent"]
>;
readonly defineComponent: UnwrapRef<
(typeof import("vue"))["defineComponent"]
>;
readonly effectScope: UnwrapRef<(typeof import("vue"))["effectScope"]>;
readonly getCurrentInstance: UnwrapRef<
(typeof import("vue"))["getCurrentInstance"]
>;
readonly getCurrentScope: UnwrapRef<
(typeof import("vue"))["getCurrentScope"]
>;
readonly h: UnwrapRef<(typeof import("vue"))["h"]>;
readonly inject: UnwrapRef<(typeof import("vue"))["inject"]>;
readonly isProxy: UnwrapRef<(typeof import("vue"))["isProxy"]>;
readonly isReactive: UnwrapRef<(typeof import("vue"))["isReactive"]>;
readonly isReadonly: UnwrapRef<(typeof import("vue"))["isReadonly"]>;
readonly isRef: UnwrapRef<(typeof import("vue"))["isRef"]>;
readonly markRaw: UnwrapRef<(typeof import("vue"))["markRaw"]>;
readonly nextTick: UnwrapRef<(typeof import("vue"))["nextTick"]>;
readonly onActivated: UnwrapRef<(typeof import("vue"))["onActivated"]>;
readonly onBeforeMount: UnwrapRef<(typeof import("vue"))["onBeforeMount"]>;
readonly onBeforeUnmount: UnwrapRef<
(typeof import("vue"))["onBeforeUnmount"]
>;
readonly onBeforeUpdate: UnwrapRef<
(typeof import("vue"))["onBeforeUpdate"]
>;
readonly onDeactivated: UnwrapRef<(typeof import("vue"))["onDeactivated"]>;
readonly onErrorCaptured: UnwrapRef<
(typeof import("vue"))["onErrorCaptured"]
>;
readonly onMounted: UnwrapRef<(typeof import("vue"))["onMounted"]>;
readonly onRenderTracked: UnwrapRef<
(typeof import("vue"))["onRenderTracked"]
>;
readonly onRenderTriggered: UnwrapRef<
(typeof import("vue"))["onRenderTriggered"]
>;
readonly onScopeDispose: UnwrapRef<
(typeof import("vue"))["onScopeDispose"]
>;
readonly onServerPrefetch: UnwrapRef<
(typeof import("vue"))["onServerPrefetch"]
>;
readonly onUnmounted: UnwrapRef<(typeof import("vue"))["onUnmounted"]>;
readonly onUpdated: UnwrapRef<(typeof import("vue"))["onUpdated"]>;
readonly provide: UnwrapRef<(typeof import("vue"))["provide"]>;
readonly reactive: UnwrapRef<(typeof import("vue"))["reactive"]>;
readonly readonly: UnwrapRef<(typeof import("vue"))["readonly"]>;
readonly ref: UnwrapRef<(typeof import("vue"))["ref"]>;
readonly resolveComponent: UnwrapRef<
(typeof import("vue"))["resolveComponent"]
>;
readonly shallowReactive: UnwrapRef<
(typeof import("vue"))["shallowReactive"]
>;
readonly shallowReadonly: UnwrapRef<
(typeof import("vue"))["shallowReadonly"]
>;
readonly shallowRef: UnwrapRef<(typeof import("vue"))["shallowRef"]>;
readonly toRaw: UnwrapRef<(typeof import("vue"))["toRaw"]>;
readonly toRef: UnwrapRef<(typeof import("vue"))["toRef"]>;
readonly toRefs: UnwrapRef<(typeof import("vue"))["toRefs"]>;
readonly toValue: UnwrapRef<(typeof import("vue"))["toValue"]>;
readonly triggerRef: UnwrapRef<(typeof import("vue"))["triggerRef"]>;
readonly unref: UnwrapRef<(typeof import("vue"))["unref"]>;
readonly useAttrs: UnwrapRef<(typeof import("vue"))["useAttrs"]>;
readonly useCssModule: UnwrapRef<(typeof import("vue"))["useCssModule"]>;
readonly useCssVars: UnwrapRef<(typeof import("vue"))["useCssVars"]>;
readonly useRoute: UnwrapRef<
(typeof import("vue-router/auto"))["useRoute"]
>;
readonly useRouter: UnwrapRef<
(typeof import("vue-router/auto"))["useRouter"]
>;
readonly useSlots: UnwrapRef<(typeof import("vue"))["useSlots"]>;
readonly watch: UnwrapRef<(typeof import("vue"))["watch"]>;
readonly watchEffect: UnwrapRef<(typeof import("vue"))["watchEffect"]>;
readonly watchPostEffect: UnwrapRef<
(typeof import("vue"))["watchPostEffect"]
>;
readonly watchSyncEffect: UnwrapRef<
(typeof import("vue"))["watchSyncEffect"]
>;
readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
readonly computed: UnwrapRef<typeof import('vue')['computed']>
readonly createApp: UnwrapRef<typeof import('vue')['createApp']>
readonly customRef: UnwrapRef<typeof import('vue')['customRef']>
readonly defineAsyncComponent: UnwrapRef<typeof import('vue')['defineAsyncComponent']>
readonly defineComponent: UnwrapRef<typeof import('vue')['defineComponent']>
readonly effectScope: UnwrapRef<typeof import('vue')['effectScope']>
readonly getCurrentInstance: UnwrapRef<typeof import('vue')['getCurrentInstance']>
readonly getCurrentScope: UnwrapRef<typeof import('vue')['getCurrentScope']>
readonly h: UnwrapRef<typeof import('vue')['h']>
readonly inject: UnwrapRef<typeof import('vue')['inject']>
readonly isProxy: UnwrapRef<typeof import('vue')['isProxy']>
readonly isReactive: UnwrapRef<typeof import('vue')['isReactive']>
readonly isReadonly: UnwrapRef<typeof import('vue')['isReadonly']>
readonly isRef: UnwrapRef<typeof import('vue')['isRef']>
readonly markRaw: UnwrapRef<typeof import('vue')['markRaw']>
readonly nextTick: UnwrapRef<typeof import('vue')['nextTick']>
readonly onActivated: UnwrapRef<typeof import('vue')['onActivated']>
readonly onBeforeMount: UnwrapRef<typeof import('vue')['onBeforeMount']>
readonly onBeforeUnmount: UnwrapRef<typeof import('vue')['onBeforeUnmount']>
readonly onBeforeUpdate: UnwrapRef<typeof import('vue')['onBeforeUpdate']>
readonly onDeactivated: UnwrapRef<typeof import('vue')['onDeactivated']>
readonly onErrorCaptured: UnwrapRef<typeof import('vue')['onErrorCaptured']>
readonly onMounted: UnwrapRef<typeof import('vue')['onMounted']>
readonly onRenderTracked: UnwrapRef<typeof import('vue')['onRenderTracked']>
readonly onRenderTriggered: UnwrapRef<typeof import('vue')['onRenderTriggered']>
readonly onScopeDispose: UnwrapRef<typeof import('vue')['onScopeDispose']>
readonly onServerPrefetch: UnwrapRef<typeof import('vue')['onServerPrefetch']>
readonly onUnmounted: UnwrapRef<typeof import('vue')['onUnmounted']>
readonly onUpdated: UnwrapRef<typeof import('vue')['onUpdated']>
readonly provide: UnwrapRef<typeof import('vue')['provide']>
readonly reactive: UnwrapRef<typeof import('vue')['reactive']>
readonly readonly: UnwrapRef<typeof import('vue')['readonly']>
readonly ref: UnwrapRef<typeof import('vue')['ref']>
readonly resolveComponent: UnwrapRef<typeof import('vue')['resolveComponent']>
readonly shallowReactive: UnwrapRef<typeof import('vue')['shallowReactive']>
readonly shallowReadonly: UnwrapRef<typeof import('vue')['shallowReadonly']>
readonly shallowRef: UnwrapRef<typeof import('vue')['shallowRef']>
readonly toRaw: UnwrapRef<typeof import('vue')['toRaw']>
readonly toRef: UnwrapRef<typeof import('vue')['toRef']>
readonly toRefs: UnwrapRef<typeof import('vue')['toRefs']>
readonly toValue: UnwrapRef<typeof import('vue')['toValue']>
readonly triggerRef: UnwrapRef<typeof import('vue')['triggerRef']>
readonly unref: UnwrapRef<typeof import('vue')['unref']>
readonly useAttrs: UnwrapRef<typeof import('vue')['useAttrs']>
readonly useCssModule: UnwrapRef<typeof import('vue')['useCssModule']>
readonly useCssVars: UnwrapRef<typeof import('vue')['useCssVars']>
readonly useRoute: UnwrapRef<typeof import('vue-router/auto')['useRoute']>
readonly useRouter: UnwrapRef<typeof import('vue-router/auto')['useRouter']>
readonly useSlots: UnwrapRef<typeof import('vue')['useSlots']>
readonly watch: UnwrapRef<typeof import('vue')['watch']>
readonly watchEffect: UnwrapRef<typeof import('vue')['watchEffect']>
readonly watchPostEffect: UnwrapRef<typeof import('vue')['watchPostEffect']>
readonly watchSyncEffect: UnwrapRef<typeof import('vue')['watchSyncEffect']>
}
}

View File

@ -11,7 +11,13 @@
</v-avatar>
</template>
<v-list-item-title>{{ c.name }}</v-list-item-title>
<v-list-item-subtitle>{{ c.created_at }}</v-list-item-subtitle>
<v-list-item-subtitle>
<span>{{ c.created_at }}</span>
&nbsp;
<span v-if="c.owner == 'guest'">访客对话</span>
<span v-else-if="c.owner == 'user'">用户对话</span>
<span v-else>{{ c.owner }}</span>
</v-list-item-subtitle>
</v-list-item>
</v-slide-y-transition>
</div>
@ -37,7 +43,7 @@ import { ref } from "vue";
import { api } from "@/plugins/api";
import {
ApiV1AssistantsPost200Response,
ApiV1ChatsGet200Response,
ApiV1ChatPublicGet200Response,
RagNewInternalSchemaChatCreateRequest,
} from "@/api";
import router from "@/router";
@ -45,7 +51,7 @@ import { useChatStore } from "../../../stores/chat";
// @ts-ignore
const assistantId = router.currentRoute.value.params.id as number;
const assistant: Ref<ApiV1AssistantsPost200Response> = ref({});
const chats = ref<ApiV1ChatsGet200Response>({});
const chats = ref<ApiV1ChatPublicGet200Response>({});
const dialog = ref(false);
const chat: Ref<RagNewInternalSchemaChatCreateRequest> = ref({

View File

@ -1,6 +1,12 @@
<template>
<h3>助理 {{ assistant.data?.name }}</h3>
<div class="mb-3">
<v-btn color="primary" @click="to('/assistants/' + assistantId + '/shares')"
>公开发布助理</v-btn
>
</div>
<v-text-field
v-if="assistant.data != null"
v-model="assistant.data.name"
@ -164,5 +170,9 @@ function updateAssistant() {
api.Assistant.apiV1AssistantsIdPatch(assistantId, assistantUpdate);
}
function to(path: string) {
router.push(path);
}
refresh();
</script>

View File

@ -0,0 +1,91 @@
<template>
<h3>共享助理 {{ assistant.data?.name }}</h3>
<v-btn color="primary" @click="createShare">创建共享</v-btn>
<div class="mt-3">
<p class="mb-3">共享列表</p>
<v-row>
<v-col
v-for="s in assistantShares.data"
:key="s.id"
cols="12"
md="4"
sm="6"
>
<v-card>
<v-card-text>
<p>Api Key: {{ s.token }}</p>
</v-card-text>
<v-card-actions>
<v-btn color="primary" @click="goto(s.token ?? 0)">访问共享</v-btn>
<v-btn color="error" @click="deleteShare(s.id ?? 0)"
>删除共享</v-btn
>
</v-card-actions>
</v-card>
</v-col>
</v-row>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
import { api } from "@/plugins/api";
import router from "@/router";
import {
ApiV1AssistantsIdSharesGet200Response,
ApiV1AssistantsPost200Response,
} from "@/api";
// @ts-ignore
const assistantId = router.currentRoute.value.params.id as number;
const assistant: Ref<ApiV1AssistantsPost200Response> = ref({
data: {
name: "",
description: "",
prompt: "",
},
});
const assistantShares: Ref<ApiV1AssistantsIdSharesGet200Response> = ref({});
function getAssistant() {
api.Assistant.apiV1AssistantsIdGet(assistantId).then((res) => {
assistant.value = res.data;
});
}
function getAssistantShare() {
api.Assistant.apiV1AssistantsIdSharesGet(assistantId).then((res) => {
assistantShares.value = res.data;
});
}
function refresh() {
getAssistant();
getAssistantShare();
}
function createShare() {
api.Assistant.apiV1AssistantsIdSharesPost(assistantId).then(() => {
getAssistantShare();
});
}
function deleteShare(shareId: number) {
api.Assistant.apiV1AssistantsIdSharesShareIdDelete(assistantId, shareId).then(
() => {
getAssistantShare();
},
);
}
function goto(token: any) {
const a = document.createElement("a");
a.target = "_blank";
a.href = `/public_chat?assistant_token=${token}`;
a.click();
}
refresh();
</script>

View File

@ -69,18 +69,18 @@
</template>
<script setup lang="ts">
import { ApiV1ChatsIdMessagesGet200Response } from "@/api";
import { ref } from "vue";
import { api, conf } from "@/plugins/api";
import VueMarkdown from "vue-markdown-render";
import router from "@/router";
import { useChatStore } from "@/stores/chat";
import { ApiV1ChatPublicChatIdMessagesGet200Response } from "@/api";
const chatStore = useChatStore();
// @ts-ignore
const chatId = parseInt(useRoute().params.id as string);
const messages: Ref<ApiV1ChatsIdMessagesGet200Response> = ref({
const messages: Ref<ApiV1ChatPublicChatIdMessagesGet200Response> = ref({
data: [],
});
const input = ref("");

View File

@ -0,0 +1,267 @@
<template>
<div>
<h3 class="mb-3">聊天记录</h3>
<v-card
v-for="message in messages.data"
:key="message.id"
class="mx-auto mt-3"
width="100%"
>
<template #title>
<div class="font-weight-black">
<div v-if="message.role == 'assistant'">AI</div>
<div v-else-if="message.role == 'system'">系统</div>
<div v-else-if="message.role == 'user'" class="text-right">用户</div>
<div v-else>
{{ message.role }}
</div>
</div>
</template>
<v-card-text class="bg-surface-light pt-4">
<div
v-if="message.role == 'assistant' || message.role == 'system'"
class="text-left"
>
<vue-markdown :source="message.content" />
</div>
<div v-else-if="message.role == 'user'" class="text-right">
<vue-markdown :source="message.content" />
</div>
<div v-else>
{{ message.content }}
</div>
</v-card-text>
</v-card>
<div class="mt-3">
<div v-if="toolError" class="mb-3">
<v-alert
density="compact"
text="这个工具出现了异常,这应该不是我们的问题,如果你是此工具的开发者,请打开开发者控制台查看具体错误。"
:title="'工具 ' + toolName + ' 出现异常'"
type="warning"
></v-alert>
</div>
<div v-show="toolCalling">
<v-progress-circular
color="primary"
indeterminate
:size="16"
></v-progress-circular>
正在执行 {{ toolName }}
</div>
<v-text-field
v-model="input"
label="输入消息"
@keyup.enter="sendMessage"
></v-text-field>
<v-btn color="primary" @click="sendMessage">发送</v-btn>
<v-btn class="ml-2" color="primary" @click="clearMessages">清空</v-btn>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
import { api, conf } from "@/plugins/api";
import VueMarkdown from "vue-markdown-render";
import router from "@/router";
import {
ApiV1ChatPublicChatIdMessagesGet200Response,
RagNewInternalSchemaChatPublicRequest,
RagNewInternalSchemaGetPublicChatMessageRequest,
} from "@/api";
import { usePublicChatStore } from "@/stores/public_chat";
const publicChatStore = usePublicChatStore();
if (publicChatStore.guest_id === "") {
publicChatStore.generateGuestId();
}
const chatId = ref(0);
//
const queries = new URLSearchParams(window.location.search);
const requiredQuries = ["assistant_token"];
for (const query of requiredQuries) {
if (!queries.has(query)) {
router.push("/");
}
}
const messages: Ref<ApiV1ChatPublicChatIdMessagesGet200Response> = ref({
data: [],
});
const publicChatInfo: Ref<RagNewInternalSchemaGetPublicChatMessageRequest> =
ref({
assistant_token: queries.get("assistant_token") as string,
guest_id: publicChatStore.guest_id,
});
const currentDate = new Date();
const publicNewChat: Ref<RagNewInternalSchemaChatPublicRequest> = ref({
assistant_token: publicChatInfo.value.assistant_token,
name: currentDate.toLocaleDateString() + " 时的对话",
guest_id: publicChatStore.guest_id,
});
const input = ref("");
const toolName = ref("");
const toolError = ref(false);
const toolCalling = ref(false);
function sendMessage() {
if (input.value !== "") {
toolError.value = false;
api.ChatPublic.apiV1ChatPublicChatIdMessagesPost(chatId.value, {
message: input.value,
assistant_token: publicChatInfo.value.assistant_token,
guest_id: publicChatStore.guest_id,
})
.then((res) => {
const newMessage = {
content: input.value,
role: "user",
};
if (messages.value.data == null) {
messages.value.data = [newMessage];
} else {
messages.value.data?.push(newMessage);
}
const streamId = res.data.data?.stream_id;
if (streamId) {
streamChat(streamId);
}
})
.catch((err) => {
// if 409
if (err.response.status === 409) {
const streamId = err.response.data.data?.stream_id;
if (streamId) {
streamChat(streamId);
}
}
});
}
}
function streamChat(streamId: String) {
const url = conf.basePath + "/api/v1/stream/" + streamId;
const evtSource = new EventSource(url);
let messageAdded = false;
//
window.scrollTo(0, document.body.scrollHeight);
let i = 0;
evtSource.addEventListener("data", (e) => {
const data = JSON.parse(e.data);
console.log(data.state);
let append = true;
switch (data.state) {
case "tool_calling":
toolCalling.value = true;
toolName.value =
data.tool_call_message.tool_name +
" 中的 " +
data.tool_call_message.function_name;
break;
case "tool_response":
setTimeout(() => {
toolName.value = "";
toolCalling.value = false;
}, 300);
break;
case "tool_failed":
toolName.value =
data.tool_response_message.tool_name +
" 中的 " +
data.tool_response_message.function_name;
toolError.value = true;
append = false;
setTimeout(() => {
toolCalling.value = false;
}, 300);
break;
case "chunk":
if (!messageAdded) {
const newMessage = {
content: "",
role: "assistant",
};
if (messages.value.data == null) {
messages.value.data = [newMessage];
} else {
// add to messages
messages.value.data?.push(newMessage);
}
messageAdded = true;
append = true;
// set index
i = (messages.value.data?.length ?? 1) - 1;
}
}
if (append && messageAdded) {
// @ts-ignore
messages.value.data[i].content += data.content;
}
});
// close
evtSource.addEventListener("close", () => {
evtSource.close();
});
}
const getMessages = () => {
api.ChatPublic.apiV1ChatPublicChatIdMessagesGet(
chatId.value,
publicChatInfo.value.assistant_token,
publicChatInfo.value.guest_id,
).then((res) => {
messages.value = res.data;
});
};
const clearMessages = () => {
api.ChatPublic.apiV1ChatPublicChatIdClearPost(
chatId.value,
publicChatInfo.value,
).then(() => {
getMessages();
});
};
const createChat = () => {
api.ChatPublic.apiV1ChatPublicPost(publicNewChat.value).then((res) => {
if (res.data.data?.id) {
chatId.value = res.data.data.id;
}
getMessages();
});
};
createChat();
</script>

View File

@ -2,6 +2,7 @@ import {
AssistantApi,
ChatApi,
ChatMessageApi,
ChatPublicApi,
Configuration,
PingApi,
ToolApi,
@ -29,6 +30,7 @@ const api = {
Ping: new PingApi(conf),
Tool: new ToolApi(conf),
ChatMessage: new ChatMessageApi(conf),
ChatPublic: new ChatPublicApi(conf),
};
export { api, conf };

13
src/stores/public_chat.ts Normal file
View File

@ -0,0 +1,13 @@
import { defineStore } from "pinia";
export const usePublicChatStore = defineStore("public_chat", {
persist: true,
state: () => ({
guest_id: "",
}),
actions: {
generateGuestId() {
this.guest_id = Math.random().toString(36).substring(2, 12);
},
},
});

View File

@ -22,11 +22,13 @@ declare module 'vue-router/auto-routes' {
'/assistants/': RouteRecordInfo<'/assistants/', '/assistants', Record<never, never>, Record<never, never>>,
'/assistants/[id]/chats': RouteRecordInfo<'/assistants/[id]/chats', '/assistants/:id/chats', { id: ParamValue<true> }, { id: ParamValue<false> }>,
'/assistants/[id]/edit': RouteRecordInfo<'/assistants/[id]/edit', '/assistants/:id/edit', { id: ParamValue<true> }, { id: ParamValue<false> }>,
'/assistants/[id]/shares': RouteRecordInfo<'/assistants/[id]/shares', '/assistants/:id/shares', { id: ParamValue<true> }, { id: ParamValue<false> }>,
'/assistants/create': RouteRecordInfo<'/assistants/create', '/assistants/create', Record<never, never>, Record<never, never>>,
'/auth/callback': RouteRecordInfo<'/auth/callback', '/auth/callback', Record<never, never>, Record<never, never>>,
'/auth/login': RouteRecordInfo<'/auth/login', '/auth/login', Record<never, never>, Record<never, never>>,
'/chats/[id]/': RouteRecordInfo<'/chats/[id]/', '/chats/:id', { id: ParamValue<true> }, { id: ParamValue<false> }>,
'/ping/': RouteRecordInfo<'/ping/', '/ping', Record<never, never>, Record<never, never>>,
'/public_chat/': RouteRecordInfo<'/public_chat/', '/public_chat', Record<never, never>, Record<never, never>>,
'/tools/': RouteRecordInfo<'/tools/', '/tools', Record<never, never>, Record<never, never>>,
'/tools/create': RouteRecordInfo<'/tools/create', '/tools/create', Record<never, never>, Record<never, never>>,
'/tools/validate': RouteRecordInfo<'/tools/validate', '/tools/validate', Record<never, never>, Record<never, never>>,