workflow.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. }
  25. created_at: number
  26. created_by: {
  27. id: string
  28. name: string
  29. email: string
  30. }
  31. finished_at: number
  32. extras?: any
  33. expand?: boolean // for UI
  34. }
  35. export type FetchWorkflowDraftResponse = {
  36. id: string
  37. graph: {
  38. nodes: Node[]
  39. edges: Edge[]
  40. viewport?: Viewport
  41. }
  42. features?: any
  43. created_at: number
  44. created_by: {
  45. id: string
  46. name: string
  47. email: string
  48. }
  49. hash: string
  50. updated_at: number
  51. }
  52. export type NodeTracingListResponse = {
  53. data: NodeTracing[]
  54. }
  55. export type WorkflowStartedResponse = {
  56. task_id: string
  57. workflow_run_id: string
  58. event: string
  59. data: {
  60. id: string
  61. workflow_id: string
  62. sequence_number: number
  63. created_at: number
  64. }
  65. }
  66. export type WorkflowFinishedResponse = {
  67. task_id: string
  68. workflow_run_id: string
  69. event: string
  70. data: {
  71. id: string
  72. workflow_id: string
  73. status: string
  74. outputs: any
  75. error: string
  76. elapsed_time: number
  77. total_tokens: number
  78. total_steps: number
  79. created_at: number
  80. finished_at: number
  81. }
  82. }
  83. export type NodeStartedResponse = {
  84. task_id: string
  85. workflow_run_id: string
  86. event: string
  87. data: {
  88. id: string
  89. node_id: string
  90. node_type: string
  91. index: number
  92. predecessor_node_id?: string
  93. inputs: any
  94. created_at: number
  95. extras?: any
  96. }
  97. }
  98. export type NodeFinishedResponse = {
  99. task_id: string
  100. workflow_run_id: string
  101. event: string
  102. data: {
  103. id: string
  104. node_id: string
  105. node_type: string
  106. index: number
  107. predecessor_node_id?: string
  108. inputs: any
  109. process_data: any
  110. outputs: any
  111. status: string
  112. error: string
  113. elapsed_time: number
  114. execution_metadata: {
  115. total_tokens: number
  116. total_price: number
  117. currency: string
  118. }
  119. created_at: number
  120. }
  121. }
  122. export type TextChunkResponse = {
  123. task_id: string
  124. workflow_run_id: string
  125. event: string
  126. data: {
  127. text: string
  128. }
  129. }
  130. export type TextReplaceResponse = {
  131. task_id: string
  132. workflow_run_id: string
  133. event: string
  134. data: {
  135. text: string
  136. }
  137. }
  138. export type WorkflowRunHistory = {
  139. id: string
  140. sequence_number: number
  141. version: string
  142. conversation_id?: string
  143. message_id?: string
  144. graph: {
  145. nodes: Node[]
  146. edges: Edge[]
  147. viewport?: Viewport
  148. }
  149. inputs: Record<string, string>
  150. status: string
  151. outputs: Record<string, any>
  152. error?: string
  153. elapsed_time: number
  154. total_tokens: number
  155. total_steps: number
  156. created_at: number
  157. finished_at: number
  158. created_by_account: {
  159. id: string
  160. name: string
  161. email: string
  162. }
  163. }
  164. export type WorkflowRunHistoryResponse = {
  165. data: WorkflowRunHistory[]
  166. }
  167. export type ChatRunHistoryResponse = {
  168. data: WorkflowRunHistory[]
  169. }
  170. export type NodesDefaultConfigsResponse = {
  171. type: string
  172. config: any
  173. }[]