-
Notifications
You must be signed in to change notification settings - Fork 125
Expand file tree
/
Copy pathview_models.py
More file actions
2591 lines (2163 loc) · 79.6 KB
/
view_models.py
File metadata and controls
2591 lines (2163 loc) · 79.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright 2025 ApeCloud, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# generated by datamodel-codegen:
# filename: openapi.merged.yaml
# timestamp: 2026-01-13T12:50:23+00:00
from __future__ import annotations
from datetime import datetime
from typing import Any, Literal, Optional, Union
from pydantic import BaseModel, ConfigDict, EmailStr, Field, RootModel, confloat, conint
class ModelSpec(BaseModel):
model: Optional[str] = Field(
None,
description='The name of the language model to use',
examples=['gpt-4o-mini'],
)
model_service_provider: Optional[str] = Field(
None,
description='Used for querying auth information (api_key/api_base/...) for a model service provider.',
examples=['openai'],
)
custom_llm_provider: Optional[str] = Field(
None,
description="Used for Non-OpenAI LLMs (e.g. 'bedrock' for amazon.titan-tg1-large)",
examples=['openai'],
)
temperature: Optional[confloat(ge=0.0, le=2.0)] = Field(
0.1,
description='Controls randomness in the output. Values between 0 and 2. Lower values make output more focused and deterministic',
examples=[0.1],
)
max_tokens: Optional[conint(ge=1)] = Field(
None, description='Maximum number of tokens to generate', examples=[4096]
)
max_completion_tokens: Optional[conint(ge=1)] = Field(
None,
description='Upper bound for generated completion tokens, including visible and reasoning tokens',
examples=[4096],
)
timeout: Optional[conint(ge=1)] = Field(
None, description='Maximum execution time in seconds for the API request'
)
top_n: Optional[conint(ge=1)] = Field(
None, description='Number of top results to return when reranking documents'
)
tags: Optional[list[str]] = Field(
[],
description='Tags for model categorization',
examples=[['free', 'recommend']],
)
class KnowledgeGraphConfig(BaseModel):
"""
Configuration for knowledge graph generation
"""
language: Optional[str] = Field(
'English',
description='Language for entity extraction and query responses',
examples=['English'],
)
entity_types: Optional[list[str]] = Field(
[
'organization',
'person',
'geo',
'event',
'product',
'technology',
'date',
'category',
],
description='List of entity types to extract during graph indexing',
examples=[['organization', 'person', 'geo', 'event']],
)
class CollectionConfig(BaseModel):
source: Optional[str] = Field(
None, description='Source system identifier', examples=['system']
)
enable_vector: Optional[bool] = Field(
True, description='Whether to enable vector index'
)
enable_fulltext: Optional[bool] = Field(
True, description='Whether to enable fulltext index'
)
enable_knowledge_graph: Optional[bool] = Field(
True, description='Whether to enable knowledge graph index'
)
enable_summary: Optional[bool] = Field(
False, description='Whether to enable summary index'
)
enable_vision: Optional[bool] = Field(
False, description='Whether to enable vision index'
)
knowledge_graph_config: Optional[KnowledgeGraphConfig] = Field(
default_factory=lambda: KnowledgeGraphConfig.model_validate(
{
'language': 'English',
'entity_types': [
'organization',
'person',
'geo',
'event',
'product',
'technology',
'date',
'category',
],
}
)
)
embedding: Optional[ModelSpec] = None
completion: Optional[ModelSpec] = None
path: Optional[str] = Field(None, description='Path for local and ftp sources')
host: Optional[str] = Field(None, description='FTP host')
username: Optional[str] = Field(None, description='FTP username')
password: Optional[str] = Field(None, description='FTP password')
region: Optional[str] = Field(None, description='Region for S3/OSS')
access_key_id: Optional[str] = Field(None, description='Access key ID for S3/OSS')
secret_access_key: Optional[str] = Field(
None, description='Secret access key for S3/OSS'
)
bucket: Optional[str] = Field(None, description='Bucket name for S3/OSS')
dir: Optional[str] = Field(None, description='Directory path in bucket for S3/OSS')
email_source: Optional[dict[str, Any]] = Field(
None, description='Email source configuration'
)
pop_server: Optional[str] = Field(None, description='POP3 server address')
port: Optional[str] = Field(None, description='Email server port')
email_address: Optional[str] = Field(None, description='Email address')
email_password: Optional[str] = Field(None, description='Email password')
app_id: Optional[str] = Field(None, description='Feishu app ID')
app_secret: Optional[str] = Field(None, description='Feishu app secret')
space_id: Optional[str] = Field(None, description='Feishu space ID')
class Local(BaseModel):
path: Optional[str] = None
class Bucket(BaseModel):
bucket: Optional[str] = None
dir: Optional[str] = None
class Oss(BaseModel):
access_key_id: Optional[str] = None
access_key_secret: Optional[str] = None
buckets: Optional[list[Bucket]] = None
bucket: Optional[str] = None
endpoint: Optional[str] = None
region: Optional[str] = None
dir: Optional[str] = None
class S3(BaseModel):
access_key_id: Optional[str] = None
access_key_secret: Optional[str] = None
buckets: Optional[list[dict[str, Any]]] = None
bucket: Optional[str] = None
region: Optional[str] = None
dir: Optional[str] = None
class Ftp(BaseModel):
path: Optional[str] = None
host: Optional[str] = None
port: Optional[float] = None
username: Optional[str] = None
class Email(BaseModel):
pop_server: Optional[str] = None
port: Optional[float] = None
email_address: Optional[str] = None
email_password: Optional[str] = None
detect_spam: Optional[bool] = None
class Url(BaseModel):
url: Optional[str] = None
name: Optional[str] = None
class Feishu(BaseModel):
app_id: Optional[str] = None
app_secret: Optional[str] = None
space_id: Optional[str] = None
node_id: Optional[str] = None
method: Optional[str] = None
target_format: Optional[str] = None
class CollectionSource(BaseModel):
category: Optional[
Literal[
'upload', 'tencent', 'oss', 'local', 's3', 'ftp', 'email', 'url', 'github'
]
] = None
upload: Optional[dict[str, Any]] = None
local: Optional[Local] = None
oss: Optional[Oss] = None
s3: Optional[S3] = None
ftp: Optional[Ftp] = None
email: Optional[Email] = None
url: Optional[Url] = None
feishu: Optional[Feishu] = None
class Collection(BaseModel):
"""
Collection is a collection of documents
"""
id: Optional[str] = None
title: Optional[str] = None
type: Optional[str] = None
description: Optional[str] = None
config: Optional[CollectionConfig] = None
source: Optional[CollectionSource] = None
status: Optional[Literal['ACTIVE', 'INACTIVE', 'DELETED']] = None
created: Optional[datetime] = None
updated: Optional[datetime] = None
is_published: Optional[bool] = Field(
False, description='Whether the collection is published to marketplace'
)
published_at: Optional[datetime] = Field(
None, description='Publication time, null when not published'
)
class Retry(BaseModel):
max_attempts: Optional[int] = Field(
None, description='Maximum number of retry attempts', examples=[3]
)
delay: Optional[int] = Field(
None, description='Delay between retries in seconds', examples=[5]
)
class Notification(BaseModel):
email: Optional[list[EmailStr]] = Field(None, examples=[['admin@example.com']])
class ErrorHandling(BaseModel):
strategy: Optional[Literal['stop_on_error', 'continue_on_error']] = Field(
None, description='Error handling strategy', examples=['stop_on_error']
)
notification: Optional[Notification] = None
class ExecutionConfig(BaseModel):
"""
Configuration for workflow execution
"""
timeout: Optional[int] = Field(
None, description='Overall timeout in seconds', examples=[300]
)
retry: Optional[Retry] = None
error_handling: Optional[ErrorHandling] = None
class SchemaDefinition(BaseModel):
"""
JSON Schema definition
"""
model_config = ConfigDict(
extra='allow',
)
type: Optional[
Literal['object', 'array', 'string', 'number', 'integer', 'boolean']
] = None
properties: Optional[dict[str, Any]] = None
required: Optional[list[str]] = None
additionalProperties: Optional[bool] = None
class Input(BaseModel):
schema_: SchemaDefinition = Field(..., alias='schema')
values: Optional[dict[str, Any]] = Field(
None, description='Default values and template references'
)
class Output(BaseModel):
schema_: SchemaDefinition = Field(..., alias='schema')
class Data(BaseModel):
input: Input
output: Output
collapsed: Optional[bool] = Field(
None,
description='Whether the node is collapsed, only useful for frontend to collapse the node',
examples=[False],
)
class Position(BaseModel):
"""
Position of the node in the frontend
"""
x: Optional[float] = None
y: Optional[float] = None
class Measured(BaseModel):
"""
Measured position of the node, only useful for frontend to measure the node
"""
width: Optional[float] = None
height: Optional[float] = None
class Node(BaseModel):
id: str = Field(
...,
description='Unique identifier for the node',
examples=['vector_search_3f8e2c1a'],
)
ariaLabel: Optional[str] = Field(None, description='label for the node')
type: Literal[
'start',
'vector_search',
'fulltext_search',
'graph_search',
'merge',
'rerank',
'llm',
] = Field(..., description='Type of node', examples=['vector_search'])
title: Optional[str] = Field(
None, description='Human-readable title of the node', examples=['Vector Search']
)
data: Data
position: Optional[Position] = Field(
None, description='Position of the node in the frontend'
)
dragHandle: Optional[str] = Field(
None,
description='Drag handle of the node, only useful for frontend to drag the node',
)
measured: Optional[Measured] = Field(
None,
description='Measured position of the node, only useful for frontend to measure the node',
)
selected: Optional[bool] = Field(
None,
description='Whether the node is selected, only useful for frontend to select the node',
)
deletable: Optional[bool] = Field(
None,
description='Whether the node is deletable, only useful for frontend to delete the node',
examples=[True],
)
class Edge(BaseModel):
id: Optional[str] = Field(
None,
description='Unique identifier for the edge, only useful for frontend to identify the edge',
examples=['edge_1'],
)
deletable: Optional[bool] = Field(
None,
description='Whether the edge is deletable, only useful for frontend to delete the edge',
examples=[True],
)
type: Optional[str] = Field(None, description='Type of the edge', examples=['edge'])
source: str = Field(..., description='ID of the source node', examples=['start'])
target: str = Field(
..., description='ID of the target node', examples=['vector_search_3f8e2c1a']
)
class WorkflowStyle(BaseModel):
"""
Workflow style
"""
edgeType: Optional[
Literal['straight', 'step', 'smoothstep', 'default', 'simplebezier']
] = None
layoutDirection: Optional[Literal['TB', 'LR']] = None
class WorkflowDefinition(BaseModel):
name: str = Field(
...,
description='Machine-readable identifier for the workflow',
examples=['rag_flow'],
)
title: str = Field(
...,
description='Human-readable title of the workflow',
examples=['RAG Knowledge Base Flow'],
)
description: Optional[str] = Field(
None,
description='Detailed description of the workflow',
examples=['A typical RAG flow with parallel retrieval and reranking'],
)
version: str = Field(
..., description='Version number of the workflow definition', examples=['1.0.0']
)
execution: Optional[ExecutionConfig] = None
schema_: Optional[dict[str, SchemaDefinition]] = Field(
None,
alias='schema',
description='Custom schema definitions used across the workflow',
)
nodes: list[Node] = Field(..., description='List of nodes in the workflow')
edges: list[Edge] = Field(
..., description='List of edges connecting nodes in the workflow'
)
style: Optional[WorkflowStyle] = None
class Agent(BaseModel):
completion: Optional[ModelSpec] = None
system_prompt_template: Optional[str] = None
query_prompt_template: Optional[str] = None
collections: Optional[list[Collection]] = None
class BotConfig(BaseModel):
agent: Optional[Agent] = None
flow: Optional[WorkflowDefinition] = None
class Bot(BaseModel):
id: Optional[str] = None
title: Optional[str] = None
description: Optional[str] = None
type: Optional[Literal['knowledge', 'common', 'agent']] = Field(
None, description='The type of bot', examples=['knowledge']
)
config: Optional[BotConfig] = None
created: Optional[datetime] = None
updated: Optional[datetime] = None
class PageResult(BaseModel):
"""
PageResult info (deprecated, use paginatedResponse instead)
"""
page_number: Optional[int] = Field(None, description='The page number')
page_size: Optional[int] = Field(None, description='The page size')
count: Optional[int] = Field(None, description='The total count of items')
class BotList(BaseModel):
"""
A list of bots
"""
items: Optional[list[Bot]] = None
pageResult: Optional[PageResult] = None
class FailResponse(BaseModel):
code: Optional[str] = Field(None, description='Error code', examples=['400'])
message: Optional[str] = Field(
None, description='Error message', examples=['Invalid request']
)
class BotCreate(BaseModel):
title: Optional[str] = None
description: Optional[str] = None
type: Optional[Literal['knowledge', 'common', 'agent']] = Field(
None, description='The type of bot', examples=['knowledge']
)
config: Optional[BotConfig] = None
class BotUpdate(BaseModel):
id: Optional[str] = None
title: Optional[str] = None
description: Optional[str] = None
config: Optional[BotConfig] = None
class DebugFlowRequest(BaseModel):
query: str
class Chat(BaseModel):
id: Optional[str] = None
title: Optional[str] = None
bot_id: Optional[str] = None
peer_id: Optional[str] = None
peer_type: Optional[
Literal['system', 'feishu', 'weixin', 'weixin_official', 'web', 'dingtalk']
] = None
status: Optional[Literal['active', 'archived']] = None
created: Optional[datetime] = None
updated: Optional[datetime] = None
class PaginatedResponse(BaseModel):
total: Optional[conint(ge=0)] = Field(
None, description='Total number of items', examples=[100]
)
page: Optional[conint(ge=1)] = Field(
None, description='Current page number', examples=[1]
)
page_size: Optional[conint(ge=1)] = Field(
None, description='Number of items per page', examples=[10]
)
total_pages: Optional[conint(ge=1)] = Field(
None, description='Total number of pages', examples=[10]
)
has_next: Optional[bool] = Field(
None, description='Whether there is a next page', examples=[True]
)
has_prev: Optional[bool] = Field(
None, description='Whether there is a previous page', examples=[False]
)
class ChatList(PaginatedResponse):
"""
A list of chats with pagination
"""
items: Optional[list[Chat]] = None
class ChatCreate(BaseModel):
title: Optional[str] = None
class Reference(BaseModel):
score: Optional[float] = None
text: Optional[str] = None
image_uri: Optional[str] = None
metadata: Optional[dict[str, Any]] = None
class Feedback(BaseModel):
type: Optional[Literal['good', 'bad']] = None
tag: Optional[Literal['Harmful', 'Unsafe', 'Fake', 'Unhelpful', 'Other']] = None
message: Optional[str] = None
class File(BaseModel):
id: Optional[str] = None
name: Optional[str] = None
class ChatMessage(BaseModel):
id: Optional[str] = None
part_id: Optional[str] = None
type: Optional[
Literal[
'welcome',
'message',
'start',
'stop',
'error',
'tool_call_result',
'thinking',
'references',
]
] = None
timestamp: Optional[float] = None
role: Optional[Literal['human', 'ai']] = None
data: Optional[str] = None
references: Optional[list[Reference]] = None
urls: Optional[list[str]] = None
feedback: Optional[Feedback] = None
files: Optional[list[File]] = None
class ChatDetails(BaseModel):
id: Optional[str] = None
title: Optional[str] = None
bot_id: Optional[str] = None
peer_id: Optional[str] = None
peer_type: Optional[
Literal['system', 'feishu', 'weixin', 'weixin_official', 'web', 'dingtalk']
] = None
history: Optional[list[list[ChatMessage]]] = Field(
None,
description='Array of conversation turns, where each turn is an array of message parts',
)
status: Optional[Literal['active', 'archived']] = None
created: Optional[datetime] = None
updated: Optional[datetime] = None
class ChatUpdate(BaseModel):
title: Optional[str] = None
class TitleGenerateRequest(BaseModel):
max_length: Optional[conint(ge=6, le=50)] = Field(
20, description='Maximum length of the generated title'
)
language: Optional[Literal['zh-CN', 'en-US', 'ja-JP', 'ko-KR']] = Field(
'zh-CN', description='Language for the title generation (IETF BCP 47 tag)'
)
turns: Optional[conint(ge=1)] = Field(
1, description='Number of most recent conversation turns to consider'
)
class TitleGenerateResponse(BaseModel):
title: str = Field(..., description='Generated title string')
class Document(BaseModel):
id: Optional[str] = None
name: Optional[str] = None
status: Optional[
Literal[
'UPLOADED',
'EXPIRED',
'PENDING',
'RUNNING',
'COMPLETE',
'FAILED',
'DELETING',
'DELETED',
]
] = None
vector_index_status: Optional[
Literal[
'PENDING',
'CREATING',
'ACTIVE',
'DELETING',
'DELETION_IN_PROGRESS',
'FAILED',
'SKIPPED',
]
] = None
fulltext_index_status: Optional[
Literal[
'PENDING',
'CREATING',
'ACTIVE',
'DELETING',
'DELETION_IN_PROGRESS',
'FAILED',
'SKIPPED',
]
] = None
graph_index_status: Optional[
Literal[
'PENDING',
'CREATING',
'ACTIVE',
'DELETING',
'DELETION_IN_PROGRESS',
'FAILED',
'SKIPPED',
]
] = None
summary_index_status: Optional[
Literal[
'PENDING',
'CREATING',
'ACTIVE',
'DELETING',
'DELETION_IN_PROGRESS',
'FAILED',
'SKIPPED',
]
] = None
vision_index_status: Optional[
Literal[
'PENDING',
'CREATING',
'ACTIVE',
'DELETING',
'DELETION_IN_PROGRESS',
'FAILED',
'SKIPPED',
]
] = None
vector_index_updated: Optional[datetime] = Field(
None, description='Vector index last updated time'
)
fulltext_index_updated: Optional[datetime] = Field(
None, description='Fulltext index last updated time'
)
graph_index_updated: Optional[datetime] = Field(
None, description='Graph index last updated time'
)
summary_index_updated: Optional[datetime] = Field(
None, description='Summary index last updated time'
)
vision_index_updated: Optional[datetime] = Field(
None, description='Vision index last updated time'
)
summary: Optional[str] = Field(None, description='Summary of the document')
size: Optional[float] = None
created: Optional[datetime] = None
updated: Optional[datetime] = None
class CollectionView(BaseModel):
"""
Lightweight collection information for lists, MCP and agents
"""
id: Optional[str] = None
title: Optional[str] = None
description: Optional[str] = None
type: Optional[str] = None
status: Optional[Literal['ACTIVE', 'INACTIVE', 'DELETED']] = None
created: Optional[datetime] = None
updated: Optional[datetime] = None
is_published: Optional[bool] = False
published_at: Optional[datetime] = Field(
None, description='Publication time, null when not published'
)
owner_user_id: Optional[str] = Field(None, description='Collection owner user ID')
owner_username: Optional[str] = Field(None, description='Collection owner username')
subscription_id: Optional[str] = Field(
None,
description='Subscription ID if this is a subscribed collection, null for owned collections',
)
subscribed_at: Optional[datetime] = Field(
None, description='Subscription time, null for owned collections'
)
class CollectionViewList(BaseModel):
"""
A list of collection views
"""
items: Optional[list[CollectionView]] = None
pageResult: Optional[PageResult] = None
class CollectionCreate(BaseModel):
title: Optional[str] = None
config: Optional[CollectionConfig] = None
type: Optional[str] = None
description: Optional[str] = None
source: Optional[CollectionSource] = None
class CollectionUpdate(BaseModel):
title: Optional[str] = None
description: Optional[str] = None
config: Optional[CollectionConfig] = None
source: Optional[CollectionSource] = None
class DocumentList(PaginatedResponse):
"""
A list of documents with pagination
"""
items: Optional[list[Document]] = None
class DocumentCreate(BaseModel):
title: Optional[str] = None
description: Optional[str] = None
source: Optional[str] = None
collection_id: Optional[str] = None
class RebuildIndexesRequest(BaseModel):
index_types: list[Literal['VECTOR', 'FULLTEXT', 'GRAPH', 'SUMMARY', 'VISION']] = (
Field(..., description='Types of indexes to rebuild', min_length=1)
)
class VisionChunk(BaseModel):
id: Optional[str] = None
asset_id: Optional[str] = None
text: Optional[str] = None
metadata: Optional[dict[str, Any]] = None
class Chunk(BaseModel):
id: Optional[str] = None
text: Optional[str] = None
metadata: Optional[dict[str, Any]] = None
class DocumentPreview(BaseModel):
doc_object_path: Optional[str] = Field(
None, description='The path to the document object.'
)
doc_filename: Optional[str] = Field(None, description='The name of the document.')
converted_pdf_object_path: Optional[str] = Field(
None, description='The path to the converted PDF object.'
)
markdown_content: Optional[str] = Field(
None, description='The markdown content of the document.'
)
chunks: Optional[list[Chunk]] = None
vision_chunks: Optional[list[VisionChunk]] = None
class UploadDocumentResponse(BaseModel):
document_id: str = Field(..., description='ID of the uploaded document')
filename: str = Field(..., description='Name of the uploaded file')
size: int = Field(..., description='Size of the uploaded file in bytes')
status: Literal[
'UPLOADED', 'PENDING', 'RUNNING', 'COMPLETE', 'FAILED', 'DELETED', 'EXPIRED'
] = Field(
...,
description='Status of the document (UPLOADED for new uploads, or existing status for duplicate files)',
)
class ConfirmDocumentsRequest(BaseModel):
document_ids: list[str] = Field(
..., description='List of document IDs to confirm', min_length=1
)
class FailedDocument(BaseModel):
document_id: Optional[str] = None
name: Optional[str] = Field(None, description='Name of the document')
error: Optional[str] = None
class ConfirmDocumentsResponse(BaseModel):
confirmed_count: int = Field(
..., description='Number of documents successfully confirmed'
)
failed_count: int = Field(
..., description='Number of documents that failed to confirm'
)
failed_documents: Optional[list[FailedDocument]] = Field(
None, description='Details of failed confirmations'
)
class VectorSearchParams(BaseModel):
topk: Optional[int] = Field(None, description='Top K results')
similarity: Optional[confloat(ge=0.0, le=1.0)] = Field(
None, description='Similarity threshold'
)
class FulltextSearchParams(BaseModel):
topk: Optional[int] = Field(None, description='Top K results')
keywords: Optional[list[str]] = Field(
None, description='Custom keywords to use for fulltext search'
)
class GraphSearchParams(BaseModel):
topk: Optional[int] = Field(None, description='Top K results')
class SummarySearchParams(BaseModel):
topk: Optional[int] = Field(None, description='Top K results')
similarity: Optional[confloat(ge=0.0, le=1.0)] = Field(
None, description='Similarity threshold'
)
class VisionSearchParams(BaseModel):
topk: Optional[int] = Field(None, description='Top K results')
similarity: Optional[confloat(ge=0.0, le=1.0)] = Field(
None, description='Similarity threshold'
)
class SearchResultItem(BaseModel):
rank: Optional[int] = Field(None, description='Result rank')
score: Optional[float] = Field(None, description='Result score')
content: Optional[str] = Field(None, description='Result content')
source: Optional[str] = Field(None, description='Source document or metadata')
recall_type: Optional[
Literal[
'vector_search',
'graph_search',
'fulltext_search',
'summary_search',
'vision_search',
]
] = Field(None, description='Recall type')
metadata: Optional[dict[str, Any]] = Field(
None, description='Metadata of the result'
)
class SearchResult(BaseModel):
id: Optional[str] = Field(None, description='The id of the search result')
query: Optional[str] = None
vector_search: Optional[VectorSearchParams] = None
fulltext_search: Optional[FulltextSearchParams] = None
graph_search: Optional[GraphSearchParams] = None
summary_search: Optional[SummarySearchParams] = None
vision_search: Optional[VisionSearchParams] = None
items: Optional[list[SearchResultItem]] = None
created: Optional[datetime] = Field(
None, description='The creation time of the search result'
)
class SearchResultList(BaseModel):
"""
A list of search results
"""
items: Optional[list[SearchResult]] = None
class SearchRequest(BaseModel):
"""
Search request
"""
query: Optional[str] = None
vector_search: Optional[VectorSearchParams] = None
fulltext_search: Optional[FulltextSearchParams] = None
graph_search: Optional[GraphSearchParams] = None
summary_search: Optional[SummarySearchParams] = None
vision_search: Optional[VisionSearchParams] = None
save_to_history: Optional[bool] = Field(
False,
description='Whether to save search result to database history',
examples=[True],
)
rerank: Optional[bool] = Field(
False,
description='Whether to enable rerank for search results',
examples=[True],
)
class Settings(BaseModel):
use_mineru: Optional[bool] = Field(None, description='Whether to use MinerU')
mineru_api_token: Optional[str] = Field(None, description='API token for MinerU')
use_doc_ray: Optional[bool] = Field(None, description='Whether to use DocRay')
use_markitdown: Optional[bool] = Field(
None, description='Whether to use MarkItDown'
)
class GraphLabelsResponse(BaseModel):
"""
Response containing available graph labels
"""
labels: list[str] = Field(
...,
description='List of available node labels in the knowledge graph',
examples=[['墨香居', '李明华', '林晓雯', '深夜读书会']],
)
class Properties(BaseModel):
"""
Node properties containing entity metadata
"""
model_config = ConfigDict(
extra='allow',
)
entity_id: Optional[str] = Field(
None, description='Entity identifier', examples=['墨香居']
)
entity_type: Optional[str] = Field(
None, description='Type of the entity', examples=['organization']
)
description: Optional[str] = Field(
None,
description='Description of the entity',
examples=[
'墨香居是这条老巷子里唯一的旧书店,经营着各种书籍,承载了老板李明华的情怀。'
],
)