Skip to content

Commit 76b17aa

Browse files
authored
Merge pull request #70 from DEEIX-AI/export_json
feat: add conversation export functionality with API and UI integration
2 parents 2b05464 + e5db5fa commit 76b17aa

31 files changed

Lines changed: 935 additions & 60 deletions

backend/docs/docs.go

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5083,6 +5083,61 @@ const docTemplate = `{
50835083
}
50845084
}
50855085
},
5086+
"/conversations/{id}/export": {
5087+
"get": {
5088+
"security": [
5089+
{
5090+
"BearerAuth": []
5091+
}
5092+
],
5093+
"description": "导出当前用户单个会话的元信息、消息、运行日志和可见处理轨迹",
5094+
"consumes": [
5095+
"application/json"
5096+
],
5097+
"produces": [
5098+
"application/json"
5099+
],
5100+
"tags": [
5101+
"chat"
5102+
],
5103+
"summary": "导出会话 JSON",
5104+
"parameters": [
5105+
{
5106+
"type": "string",
5107+
"description": "会话 public_id",
5108+
"name": "id",
5109+
"in": "path",
5110+
"required": true
5111+
}
5112+
],
5113+
"responses": {
5114+
"200": {
5115+
"description": "OK",
5116+
"schema": {
5117+
"$ref": "#/definitions/internal_transport_http_conversation.ConversationExportResponseDoc"
5118+
}
5119+
},
5120+
"400": {
5121+
"description": "Bad Request",
5122+
"schema": {
5123+
"$ref": "#/definitions/internal_transport_http_conversation.ErrorDoc"
5124+
}
5125+
},
5126+
"404": {
5127+
"description": "Not Found",
5128+
"schema": {
5129+
"$ref": "#/definitions/internal_transport_http_conversation.ErrorDoc"
5130+
}
5131+
},
5132+
"500": {
5133+
"description": "Internal Server Error",
5134+
"schema": {
5135+
"$ref": "#/definitions/internal_transport_http_conversation.ErrorDoc"
5136+
}
5137+
}
5138+
}
5139+
}
5140+
},
50865141
"/conversations/{id}/messages": {
50875142
"get": {
50885143
"security": [
@@ -10937,6 +10992,72 @@ const docTemplate = `{
1093710992
}
1093810993
}
1093910994
},
10995+
"internal_transport_http_conversation.ConversationExportCompatibilityResponse": {
10996+
"type": "object",
10997+
"properties": {
10998+
"format": {
10999+
"type": "string"
11000+
},
11001+
"notes": {
11002+
"type": "string"
11003+
}
11004+
}
11005+
},
11006+
"internal_transport_http_conversation.ConversationExportResponse": {
11007+
"type": "object",
11008+
"properties": {
11009+
"compatibility": {
11010+
"$ref": "#/definitions/internal_transport_http_conversation.ConversationExportCompatibilityResponse"
11011+
},
11012+
"conversation": {
11013+
"$ref": "#/definitions/internal_transport_http_conversation.ConversationResponse"
11014+
},
11015+
"defaultMessagePublicIDs": {
11016+
"type": "array",
11017+
"items": {
11018+
"type": "string"
11019+
}
11020+
},
11021+
"exportScope": {
11022+
"type": "string"
11023+
},
11024+
"exportedAt": {
11025+
"type": "string"
11026+
},
11027+
"messages": {
11028+
"type": "array",
11029+
"items": {
11030+
"$ref": "#/definitions/internal_transport_http_conversation.MessageResponse"
11031+
}
11032+
},
11033+
"runs": {
11034+
"type": "array",
11035+
"items": {
11036+
"$ref": "#/definitions/internal_transport_http_conversation.RunResponse"
11037+
}
11038+
},
11039+
"totalMessages": {
11040+
"type": "integer"
11041+
},
11042+
"totalRuns": {
11043+
"type": "integer"
11044+
},
11045+
"version": {
11046+
"type": "integer"
11047+
}
11048+
}
11049+
},
11050+
"internal_transport_http_conversation.ConversationExportResponseDoc": {
11051+
"type": "object",
11052+
"properties": {
11053+
"data": {
11054+
"$ref": "#/definitions/internal_transport_http_conversation.ConversationExportResponse"
11055+
},
11056+
"errorMsg": {
11057+
"type": "string"
11058+
}
11059+
}
11060+
},
1094011061
"internal_transport_http_conversation.ConversationListResponseDoc": {
1094111062
"type": "object",
1094211063
"properties": {

backend/docs/swagger.json

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5076,6 +5076,61 @@
50765076
}
50775077
}
50785078
},
5079+
"/conversations/{id}/export": {
5080+
"get": {
5081+
"security": [
5082+
{
5083+
"BearerAuth": []
5084+
}
5085+
],
5086+
"description": "导出当前用户单个会话的元信息、消息、运行日志和可见处理轨迹",
5087+
"consumes": [
5088+
"application/json"
5089+
],
5090+
"produces": [
5091+
"application/json"
5092+
],
5093+
"tags": [
5094+
"chat"
5095+
],
5096+
"summary": "导出会话 JSON",
5097+
"parameters": [
5098+
{
5099+
"type": "string",
5100+
"description": "会话 public_id",
5101+
"name": "id",
5102+
"in": "path",
5103+
"required": true
5104+
}
5105+
],
5106+
"responses": {
5107+
"200": {
5108+
"description": "OK",
5109+
"schema": {
5110+
"$ref": "#/definitions/internal_transport_http_conversation.ConversationExportResponseDoc"
5111+
}
5112+
},
5113+
"400": {
5114+
"description": "Bad Request",
5115+
"schema": {
5116+
"$ref": "#/definitions/internal_transport_http_conversation.ErrorDoc"
5117+
}
5118+
},
5119+
"404": {
5120+
"description": "Not Found",
5121+
"schema": {
5122+
"$ref": "#/definitions/internal_transport_http_conversation.ErrorDoc"
5123+
}
5124+
},
5125+
"500": {
5126+
"description": "Internal Server Error",
5127+
"schema": {
5128+
"$ref": "#/definitions/internal_transport_http_conversation.ErrorDoc"
5129+
}
5130+
}
5131+
}
5132+
}
5133+
},
50795134
"/conversations/{id}/messages": {
50805135
"get": {
50815136
"security": [
@@ -10930,6 +10985,72 @@
1093010985
}
1093110986
}
1093210987
},
10988+
"internal_transport_http_conversation.ConversationExportCompatibilityResponse": {
10989+
"type": "object",
10990+
"properties": {
10991+
"format": {
10992+
"type": "string"
10993+
},
10994+
"notes": {
10995+
"type": "string"
10996+
}
10997+
}
10998+
},
10999+
"internal_transport_http_conversation.ConversationExportResponse": {
11000+
"type": "object",
11001+
"properties": {
11002+
"compatibility": {
11003+
"$ref": "#/definitions/internal_transport_http_conversation.ConversationExportCompatibilityResponse"
11004+
},
11005+
"conversation": {
11006+
"$ref": "#/definitions/internal_transport_http_conversation.ConversationResponse"
11007+
},
11008+
"defaultMessagePublicIDs": {
11009+
"type": "array",
11010+
"items": {
11011+
"type": "string"
11012+
}
11013+
},
11014+
"exportScope": {
11015+
"type": "string"
11016+
},
11017+
"exportedAt": {
11018+
"type": "string"
11019+
},
11020+
"messages": {
11021+
"type": "array",
11022+
"items": {
11023+
"$ref": "#/definitions/internal_transport_http_conversation.MessageResponse"
11024+
}
11025+
},
11026+
"runs": {
11027+
"type": "array",
11028+
"items": {
11029+
"$ref": "#/definitions/internal_transport_http_conversation.RunResponse"
11030+
}
11031+
},
11032+
"totalMessages": {
11033+
"type": "integer"
11034+
},
11035+
"totalRuns": {
11036+
"type": "integer"
11037+
},
11038+
"version": {
11039+
"type": "integer"
11040+
}
11041+
}
11042+
},
11043+
"internal_transport_http_conversation.ConversationExportResponseDoc": {
11044+
"type": "object",
11045+
"properties": {
11046+
"data": {
11047+
"$ref": "#/definitions/internal_transport_http_conversation.ConversationExportResponse"
11048+
},
11049+
"errorMsg": {
11050+
"type": "string"
11051+
}
11052+
}
11053+
},
1093311054
"internal_transport_http_conversation.ConversationListResponseDoc": {
1093411055
"type": "object",
1093511056
"properties": {

backend/docs/swagger.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2681,6 +2681,49 @@ definitions:
26812681
errorMsg:
26822682
type: string
26832683
type: object
2684+
internal_transport_http_conversation.ConversationExportCompatibilityResponse:
2685+
properties:
2686+
format:
2687+
type: string
2688+
notes:
2689+
type: string
2690+
type: object
2691+
internal_transport_http_conversation.ConversationExportResponse:
2692+
properties:
2693+
compatibility:
2694+
$ref: '#/definitions/internal_transport_http_conversation.ConversationExportCompatibilityResponse'
2695+
conversation:
2696+
$ref: '#/definitions/internal_transport_http_conversation.ConversationResponse'
2697+
defaultMessagePublicIDs:
2698+
items:
2699+
type: string
2700+
type: array
2701+
exportScope:
2702+
type: string
2703+
exportedAt:
2704+
type: string
2705+
messages:
2706+
items:
2707+
$ref: '#/definitions/internal_transport_http_conversation.MessageResponse'
2708+
type: array
2709+
runs:
2710+
items:
2711+
$ref: '#/definitions/internal_transport_http_conversation.RunResponse'
2712+
type: array
2713+
totalMessages:
2714+
type: integer
2715+
totalRuns:
2716+
type: integer
2717+
version:
2718+
type: integer
2719+
type: object
2720+
internal_transport_http_conversation.ConversationExportResponseDoc:
2721+
properties:
2722+
data:
2723+
$ref: '#/definitions/internal_transport_http_conversation.ConversationExportResponse'
2724+
errorMsg:
2725+
type: string
2726+
type: object
26842727
internal_transport_http_conversation.ConversationListResponseDoc:
26852728
properties:
26862729
data:
@@ -6807,6 +6850,41 @@ paths:
68076850
summary: 设置会话归档
68086851
tags:
68096852
- chat
6853+
/conversations/{id}/export:
6854+
get:
6855+
consumes:
6856+
- application/json
6857+
description: 导出当前用户单个会话的元信息、消息、运行日志和可见处理轨迹
6858+
parameters:
6859+
- description: 会话 public_id
6860+
in: path
6861+
name: id
6862+
required: true
6863+
type: string
6864+
produces:
6865+
- application/json
6866+
responses:
6867+
"200":
6868+
description: OK
6869+
schema:
6870+
$ref: '#/definitions/internal_transport_http_conversation.ConversationExportResponseDoc'
6871+
"400":
6872+
description: Bad Request
6873+
schema:
6874+
$ref: '#/definitions/internal_transport_http_conversation.ErrorDoc'
6875+
"404":
6876+
description: Not Found
6877+
schema:
6878+
$ref: '#/definitions/internal_transport_http_conversation.ErrorDoc'
6879+
"500":
6880+
description: Internal Server Error
6881+
schema:
6882+
$ref: '#/definitions/internal_transport_http_conversation.ErrorDoc'
6883+
security:
6884+
- BearerAuth: []
6885+
summary: 导出会话 JSON
6886+
tags:
6887+
- chat
68106888
/conversations/{id}/messages:
68116889
get:
68126890
consumes:

backend/internal/application/conversation/dto.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
package conversation
22

3+
import (
4+
"time"
5+
6+
model "github.com/DEEIX-AI/DEEIX-Chat/backend/internal/domain/conversation"
7+
)
8+
9+
// ConversationExportResult 表示单会话 JSON 导出结果。
10+
type ConversationExportResult struct {
11+
Version int
12+
ExportScope string
13+
ExportedAt time.Time
14+
Conversation *model.Conversation
15+
Messages []model.Message
16+
Runs []model.Run
17+
TotalMessages int64
18+
TotalRuns int64
19+
DefaultMessagePublicIDs []string
20+
}
21+
322
// ChatFilePolicyDTO 聊天文件策略响应(内部传输,不携带序列化标记)。
423
type ChatFilePolicyDTO struct {
524
MaxMessageFiles int

0 commit comments

Comments
 (0)