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.9KB

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