You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pipeline.ts 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. import type { Edge, EnvironmentVariable, Node, SupportUploadFileTypes } from '@/app/components/workflow/types'
  2. import type { DSLImportMode, DSLImportStatus } from './app'
  3. import type { ChunkingMode, DatasetPermission, DocumentIndexingStatus, FileIndexingEstimateResponse, IconInfo } from './datasets'
  4. import type { Dependency } from '@/app/components/plugins/types'
  5. import type { AppIconSelection } from '@/app/components/base/app-icon-picker'
  6. import type { Viewport } from 'reactflow'
  7. import type { TransferMethod } from '@/types/app'
  8. import { BaseFieldType } from '@/app/components/base/form/form-scenarios/base/types'
  9. import type { NodeRunResult } from '@/types/workflow'
  10. export enum DatasourceType {
  11. localFile = 'local_file',
  12. onlineDocument = 'online_document',
  13. websiteCrawl = 'website_crawl',
  14. onlineDrive = 'online_drive',
  15. }
  16. export type PipelineTemplateListParams = {
  17. type: 'built-in' | 'customized'
  18. }
  19. export type PipelineTemplate = {
  20. id: string
  21. name: string
  22. icon: IconInfo
  23. description: string
  24. position: number
  25. chunk_structure: ChunkingMode
  26. }
  27. export type PipelineTemplateListResponse = {
  28. pipeline_templates: PipelineTemplate[]
  29. }
  30. export type PipelineTemplateByIdRequest = {
  31. template_id: string
  32. type: 'built-in' | 'customized'
  33. }
  34. export type PipelineTemplateByIdResponse = {
  35. id: string
  36. name: string
  37. icon_info: IconInfo
  38. description: string
  39. chunk_structure: ChunkingMode
  40. export_data: string // DSL content
  41. graph: {
  42. nodes: Node[]
  43. edges: Edge[]
  44. viewport: Viewport
  45. }
  46. created_by: string
  47. }
  48. export type CreateFormData = {
  49. name: string
  50. appIcon: AppIconSelection
  51. description: string
  52. permission: DatasetPermission
  53. selectedMemberIDs: string[]
  54. }
  55. export type UpdateTemplateInfoRequest = {
  56. template_id: string
  57. name: string
  58. icon_info: IconInfo
  59. description: string
  60. }
  61. export type UpdateTemplateInfoResponse = {
  62. pipeline_id: string
  63. name: string
  64. icon: IconInfo
  65. description: string
  66. position: number
  67. }
  68. export type DeleteTemplateResponse = {
  69. code: number
  70. }
  71. export type ExportTemplateDSLResponse = {
  72. data: string
  73. }
  74. export type ImportPipelineDSLRequest = {
  75. mode: DSLImportMode
  76. yaml_content?: string
  77. yaml_url?: string
  78. pipeline_id?: string
  79. }
  80. export type ImportPipelineDSLResponse = {
  81. id: string
  82. status: DSLImportStatus
  83. pipeline_id: string
  84. dataset_id: string
  85. current_dsl_version: string
  86. imported_dsl_version: string
  87. }
  88. export type ImportPipelineDSLConfirmResponse = {
  89. status: DSLImportStatus
  90. pipeline_id: string
  91. dataset_id: string
  92. current_dsl_version: string
  93. imported_dsl_version: string
  94. error: string
  95. }
  96. export type PipelineCheckDependenciesResponse = {
  97. leaked_dependencies: Dependency[]
  98. }
  99. export enum PipelineInputVarType {
  100. textInput = 'text-input',
  101. paragraph = 'paragraph',
  102. select = 'select',
  103. number = 'number',
  104. singleFile = 'file',
  105. multiFiles = 'file-list',
  106. checkbox = 'checkbox',
  107. }
  108. export const VAR_TYPE_MAP: Record<PipelineInputVarType, BaseFieldType> = {
  109. [PipelineInputVarType.textInput]: BaseFieldType.textInput,
  110. [PipelineInputVarType.paragraph]: BaseFieldType.paragraph,
  111. [PipelineInputVarType.select]: BaseFieldType.select,
  112. [PipelineInputVarType.singleFile]: BaseFieldType.file,
  113. [PipelineInputVarType.multiFiles]: BaseFieldType.fileList,
  114. [PipelineInputVarType.number]: BaseFieldType.numberInput,
  115. [PipelineInputVarType.checkbox]: BaseFieldType.checkbox,
  116. }
  117. export type RAGPipelineVariable = {
  118. belong_to_node_id: string // indicates belong to which node or 'shared'
  119. type: PipelineInputVarType
  120. label: string
  121. variable: string
  122. max_length?: number
  123. default_value?: string
  124. placeholder?: string
  125. unit?: string
  126. required: boolean
  127. tooltips?: string
  128. options?: string[]
  129. allowed_file_upload_methods?: TransferMethod[]
  130. allowed_file_types?: SupportUploadFileTypes[]
  131. allowed_file_extensions?: string[]
  132. }
  133. export type InputVar = Omit<RAGPipelineVariable, 'belong_to_node_id'>
  134. export type RAGPipelineVariables = RAGPipelineVariable[]
  135. export type PipelineProcessingParamsRequest = {
  136. pipeline_id: string
  137. node_id: string
  138. }
  139. export type PipelineProcessingParamsResponse = {
  140. variables: RAGPipelineVariables
  141. }
  142. export type PipelinePreProcessingParamsRequest = {
  143. pipeline_id: string
  144. node_id: string
  145. }
  146. export type PipelinePreProcessingParamsResponse = {
  147. variables: RAGPipelineVariables
  148. }
  149. export type PublishedPipelineInfoResponse = {
  150. id: string
  151. graph: {
  152. nodes: Node[]
  153. edges: Edge[]
  154. viewport: Viewport
  155. }
  156. created_at: number
  157. created_by: {
  158. id: string
  159. name: string
  160. email: string
  161. }
  162. hash: string
  163. updated_at: number
  164. updated_by: {
  165. id: string
  166. name: string
  167. email: string
  168. },
  169. environment_variables?: EnvironmentVariable[]
  170. rag_pipeline_variables?: RAGPipelineVariables
  171. version: string
  172. marked_name: string
  173. marked_comment: string
  174. }
  175. export type PublishedPipelineRunRequest = {
  176. pipeline_id: string
  177. inputs: Record<string, any>
  178. start_node_id: string
  179. datasource_type: DatasourceType
  180. datasource_info_list: Array<Record<string, any>>
  181. original_document_id?: string
  182. is_preview: boolean
  183. }
  184. export type PublishedPipelineRunPreviewResponse = {
  185. task_iod: string
  186. workflow_run_id: string
  187. data: {
  188. id: string
  189. status: string
  190. created_at: number
  191. elapsed_time: number
  192. error: string
  193. finished_at: number
  194. outputs: FileIndexingEstimateResponse
  195. total_steps: number
  196. total_tokens: number
  197. workflow_id: string
  198. }
  199. }
  200. export type PublishedPipelineRunResponse = {
  201. batch: string
  202. dataset: {
  203. chunk_structure: ChunkingMode
  204. description: string
  205. id: string
  206. name: string
  207. }
  208. documents: InitialDocumentDetail[]
  209. }
  210. export type InitialDocumentDetail = {
  211. data_source_info: Record<string, any>
  212. data_source_type: DatasourceType
  213. enable: boolean
  214. error: string
  215. id: string
  216. indexing_status: DocumentIndexingStatus
  217. name: string
  218. position: number
  219. }
  220. export type PipelineExecutionLogRequest = {
  221. dataset_id: string
  222. document_id: string
  223. }
  224. export type PipelineExecutionLogResponse = {
  225. datasource_info: Record<string, any>
  226. datasource_type: DatasourceType
  227. input_data: Record<string, any>
  228. datasource_node_id: string
  229. }
  230. export type OnlineDocumentPreviewRequest = {
  231. workspaceID: string
  232. pageID: string
  233. pageType: string
  234. pipelineId: string
  235. datasourceNodeId: string
  236. credentialId: string
  237. }
  238. export type OnlineDocumentPreviewResponse = {
  239. content: string
  240. }
  241. export type ConversionResponse = {
  242. pipeline_id: string
  243. dataset_id: string
  244. status: 'success' | 'failed'
  245. }
  246. export enum OnlineDriveFileType {
  247. file = 'file',
  248. folder = 'folder',
  249. bucket = 'bucket',
  250. }
  251. export type OnlineDriveFile = {
  252. id: string
  253. name: string
  254. size?: number
  255. type: OnlineDriveFileType
  256. }
  257. export type DatasourceNodeSingleRunRequest = {
  258. pipeline_id: string
  259. start_node_id: string
  260. start_node_title: string
  261. datasource_type: DatasourceType
  262. datasource_info: Record<string, any>
  263. }
  264. export type DatasourceNodeSingleRunResponse = NodeRunResult