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 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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. export enum DatasourceType {
  9. localFile = 'local_file',
  10. onlineDocument = 'online_document',
  11. websiteCrawl = 'website_crawl',
  12. }
  13. export type PipelineTemplateListParams = {
  14. type: 'built-in' | 'customized'
  15. }
  16. export type PipelineTemplate = {
  17. id: string
  18. name: string
  19. icon: IconInfo
  20. description: string
  21. position: number
  22. chunk_structure: ChunkingMode
  23. }
  24. export type PipelineTemplateListResponse = {
  25. pipeline_templates: PipelineTemplate[]
  26. }
  27. export type PipelineTemplateByIdRequest = {
  28. template_id: string
  29. type: 'built-in' | 'customized'
  30. }
  31. export type PipelineTemplateByIdResponse = {
  32. id: string
  33. name: string
  34. icon_info: IconInfo
  35. description: string
  36. chunk_structure: ChunkingMode
  37. export_data: string // DSL content
  38. graph: {
  39. nodes: Node[]
  40. edges: Edge[]
  41. viewport: Viewport
  42. }
  43. created_by: string
  44. }
  45. export type CreateFormData = {
  46. name: string
  47. appIcon: AppIconSelection
  48. description: string
  49. permission: DatasetPermission
  50. selectedMemberIDs: string[]
  51. }
  52. export type UpdateTemplateInfoRequest = {
  53. template_id: string
  54. name: string
  55. icon_info: IconInfo
  56. description: string
  57. }
  58. export type UpdateTemplateInfoResponse = {
  59. pipeline_id: string
  60. name: string
  61. icon: IconInfo
  62. description: string
  63. position: number
  64. }
  65. export type DeleteTemplateResponse = {
  66. code: number
  67. }
  68. export type ExportTemplateDSLResponse = {
  69. data: string
  70. }
  71. export type ImportPipelineDSLRequest = {
  72. mode: DSLImportMode
  73. yaml_content?: string
  74. yaml_url?: string
  75. pipeline_id?: string
  76. }
  77. export type ImportPipelineDSLResponse = {
  78. id: string
  79. status: DSLImportStatus
  80. pipeline_id: string
  81. dataset_id: string
  82. current_dsl_version: string
  83. imported_dsl_version: string
  84. }
  85. export type ImportPipelineDSLConfirmResponse = {
  86. status: DSLImportStatus
  87. pipeline_id: string
  88. dataset_id: string
  89. current_dsl_version: string
  90. imported_dsl_version: string
  91. error: string
  92. }
  93. export type PipelineCheckDependenciesResponse = {
  94. leaked_dependencies: Dependency[]
  95. }
  96. export enum PipelineInputVarType {
  97. textInput = 'text-input',
  98. paragraph = 'paragraph',
  99. select = 'select',
  100. number = 'number',
  101. singleFile = 'file',
  102. multiFiles = 'file-list',
  103. checkbox = 'checkbox',
  104. }
  105. export type RAGPipelineVariable = {
  106. belong_to_node_id: string // indicates belong to which node or 'shared'
  107. type: PipelineInputVarType
  108. label: string
  109. variable: string
  110. max_length?: number
  111. default_value?: string
  112. placeholder?: string
  113. unit?: string
  114. required: boolean
  115. tooltips?: string
  116. options?: string[]
  117. allowed_file_upload_methods?: TransferMethod[]
  118. allowed_file_types?: SupportUploadFileTypes[]
  119. allowed_file_extensions?: string[]
  120. }
  121. export type InputVar = Omit<RAGPipelineVariable, 'belong_to_node_id'>
  122. export type RAGPipelineVariables = RAGPipelineVariable[]
  123. export type PipelineProcessingParamsRequest = {
  124. pipeline_id: string
  125. node_id: string
  126. }
  127. export type PipelineProcessingParamsResponse = {
  128. variables: RAGPipelineVariables
  129. }
  130. export type PipelinePreProcessingParamsRequest = {
  131. pipeline_id: string
  132. node_id: string
  133. }
  134. export type PipelinePreProcessingParamsResponse = {
  135. variables: RAGPipelineVariables
  136. }
  137. export type PipelineDatasourceNodeRunRequest = {
  138. pipeline_id: string
  139. node_id: string
  140. inputs: Record<string, any>
  141. datasource_type: DatasourceType
  142. }
  143. export type PipelineDatasourceNodeRunResponse = {
  144. job_id?: string
  145. status: 'processing' | 'completed'
  146. result: any
  147. provider_type: DatasourceType
  148. }
  149. export type PipelineDatasourceNodeRunStatusRequest = {
  150. pipeline_id: string
  151. node_id: string
  152. job_id: string
  153. datasource_type: DatasourceType
  154. }
  155. export type PipelineDatasourceNodeRunStatusResponse = {
  156. provider_type: DatasourceType
  157. result: Record<string, any>
  158. status: 'processing' | 'completed'
  159. job_id: string
  160. }
  161. export type PublishedPipelineInfoResponse = {
  162. id: string
  163. graph: {
  164. nodes: Node[]
  165. edges: Edge[]
  166. viewport: Viewport
  167. }
  168. created_at: number
  169. created_by: {
  170. id: string
  171. name: string
  172. email: string
  173. }
  174. hash: string
  175. updated_at: number
  176. updated_by: {
  177. id: string
  178. name: string
  179. email: string
  180. },
  181. environment_variables?: EnvironmentVariable[]
  182. rag_pipeline_variables?: RAGPipelineVariables
  183. version: string
  184. marked_name: string
  185. marked_comment: string
  186. }
  187. export type PublishedPipelineRunRequest = {
  188. pipeline_id: string
  189. inputs: Record<string, any>
  190. start_node_id: string
  191. datasource_type: DatasourceType
  192. datasource_info_list: Array<Record<string, any>>
  193. is_preview: boolean
  194. }
  195. export type PublishedPipelineRunPreviewResponse = {
  196. task_iod: string
  197. workflow_run_id: string
  198. data: {
  199. id: string
  200. status: string
  201. created_at: number
  202. elapsed_time: number
  203. error: string
  204. finished_at: number
  205. outputs: FileIndexingEstimateResponse
  206. total_steps: number
  207. total_tokens: number
  208. workflow_id: string
  209. }
  210. }
  211. export type PublishedPipelineRunResponse = {
  212. batch: string
  213. dataset: {
  214. chunk_structure: ChunkingMode
  215. description: string
  216. id: string
  217. name: string
  218. }
  219. documents: InitialDocumentDetail[]
  220. }
  221. export type InitialDocumentDetail = {
  222. data_source_info: Record<string, any>
  223. data_source_type: DatasourceType
  224. enable: boolean
  225. error: string
  226. id: string
  227. indexing_status: DocumentIndexingStatus
  228. name: string
  229. position: number
  230. }