workflow.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. import type { Viewport } from 'reactflow'
  2. import type {
  3. BlockEnum,
  4. Edge,
  5. EnvironmentVariable,
  6. Node,
  7. } from '@/app/components/workflow/types'
  8. export type NodeTracing = {
  9. id: string
  10. index: number
  11. predecessor_node_id: string
  12. node_id: string
  13. node_type: BlockEnum
  14. title: string
  15. inputs: any
  16. process_data: any
  17. outputs?: any
  18. status: string
  19. error?: string
  20. elapsed_time: number
  21. execution_metadata: {
  22. total_tokens: number
  23. total_price: number
  24. currency: string
  25. steps_boundary: number[]
  26. }
  27. metadata: {
  28. iterator_length: number
  29. }
  30. created_at: number
  31. created_by: {
  32. id: string
  33. name: string
  34. email: string
  35. }
  36. finished_at: number
  37. extras?: any
  38. expand?: boolean // for UI
  39. details?: NodeTracing[][] // iteration detail
  40. }
  41. export type FetchWorkflowDraftResponse = {
  42. id: string
  43. graph: {
  44. nodes: Node[]
  45. edges: Edge[]
  46. viewport?: Viewport
  47. }
  48. features?: any
  49. created_at: number
  50. created_by: {
  51. id: string
  52. name: string
  53. email: string
  54. }
  55. hash: string
  56. updated_at: number
  57. tool_published: boolean
  58. environment_variables?: EnvironmentVariable[]
  59. }
  60. export type NodeTracingListResponse = {
  61. data: NodeTracing[]
  62. }
  63. export type WorkflowStartedResponse = {
  64. task_id: string
  65. workflow_run_id: string
  66. event: string
  67. data: {
  68. id: string
  69. workflow_id: string
  70. sequence_number: number
  71. created_at: number
  72. }
  73. }
  74. export type WorkflowFinishedResponse = {
  75. task_id: string
  76. workflow_run_id: string
  77. event: string
  78. data: {
  79. id: string
  80. workflow_id: string
  81. status: string
  82. outputs: any
  83. error: string
  84. elapsed_time: number
  85. total_tokens: number
  86. total_steps: number
  87. created_at: number
  88. created_by: {
  89. id: string
  90. name: string
  91. email: string
  92. }
  93. finished_at: number
  94. }
  95. }
  96. export type NodeStartedResponse = {
  97. task_id: string
  98. workflow_run_id: string
  99. event: string
  100. data: {
  101. id: string
  102. node_id: string
  103. node_type: string
  104. index: number
  105. predecessor_node_id?: string
  106. inputs: any
  107. created_at: number
  108. extras?: any
  109. }
  110. }
  111. export type NodeFinishedResponse = {
  112. task_id: string
  113. workflow_run_id: string
  114. event: string
  115. data: {
  116. id: string
  117. node_id: string
  118. node_type: string
  119. index: number
  120. predecessor_node_id?: string
  121. inputs: any
  122. process_data: any
  123. outputs: any
  124. status: string
  125. error: string
  126. elapsed_time: number
  127. execution_metadata: {
  128. total_tokens: number
  129. total_price: number
  130. currency: string
  131. }
  132. created_at: number
  133. }
  134. }
  135. export type IterationStartedResponse = {
  136. task_id: string
  137. workflow_run_id: string
  138. event: string
  139. data: {
  140. id: string
  141. node_id: string
  142. metadata: {
  143. iterator_length: number
  144. }
  145. created_at: number
  146. extras?: any
  147. }
  148. }
  149. export type IterationNextedResponse = {
  150. task_id: string
  151. workflow_run_id: string
  152. event: string
  153. data: {
  154. id: string
  155. node_id: string
  156. index: number
  157. output: any
  158. extras?: any
  159. created_at: number
  160. }
  161. }
  162. export type IterationFinishedResponse = {
  163. task_id: string
  164. workflow_run_id: string
  165. event: string
  166. data: {
  167. id: string
  168. node_id: string
  169. outputs: any
  170. extras?: any
  171. status: string
  172. created_at: number
  173. error: string
  174. }
  175. }
  176. export type TextChunkResponse = {
  177. task_id: string
  178. workflow_run_id: string
  179. event: string
  180. data: {
  181. text: string
  182. }
  183. }
  184. export type TextReplaceResponse = {
  185. task_id: string
  186. workflow_run_id: string
  187. event: string
  188. data: {
  189. text: string
  190. }
  191. }
  192. export type WorkflowRunHistory = {
  193. id: string
  194. sequence_number: number
  195. version: string
  196. conversation_id?: string
  197. message_id?: string
  198. graph: {
  199. nodes: Node[]
  200. edges: Edge[]
  201. viewport?: Viewport
  202. }
  203. inputs: Record<string, string>
  204. status: string
  205. outputs: Record<string, any>
  206. error?: string
  207. elapsed_time: number
  208. total_tokens: number
  209. total_steps: number
  210. created_at: number
  211. finished_at: number
  212. created_by_account: {
  213. id: string
  214. name: string
  215. email: string
  216. }
  217. }
  218. export type WorkflowRunHistoryResponse = {
  219. data: WorkflowRunHistory[]
  220. }
  221. export type ChatRunHistoryResponse = {
  222. data: WorkflowRunHistory[]
  223. }
  224. export type NodesDefaultConfigsResponse = {
  225. type: string
  226. config: any
  227. }[]