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

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