workflow.ts 3.2 KB

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