workflow.ts 4.1 KB

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