您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. export interface ICategorizeItem {
  2. name: string;
  3. description?: string;
  4. examples?: { value: string }[];
  5. index: number;
  6. to: string[];
  7. }
  8. export type ICategorizeItemResult = Record<
  9. string,
  10. Omit<ICategorizeItem, 'name' | 'examples'> & { examples: string[] }
  11. >;
  12. export interface ISwitchCondition {
  13. items: ISwitchItem[];
  14. logical_operator: string;
  15. to: string[];
  16. }
  17. export interface ISwitchItem {
  18. cpn_id: string;
  19. operator: string;
  20. value: string;
  21. }
  22. export interface ISwitchForm {
  23. conditions: ISwitchCondition[];
  24. end_cpn_ids: string[];
  25. no: string;
  26. }
  27. import { Edge, Node } from '@xyflow/react';
  28. import { IReference, Message } from './chat';
  29. export type DSLComponents = Record<string, IOperator>;
  30. export interface DSL {
  31. components: DSLComponents;
  32. history: any[];
  33. path?: string[][];
  34. answer?: any[];
  35. graph?: IGraph;
  36. messages: Message[];
  37. reference: IReference[];
  38. globals: Record<string, any>;
  39. retrieval: IReference[];
  40. }
  41. export interface IOperator {
  42. obj: IOperatorNode;
  43. downstream: string[];
  44. upstream: string[];
  45. parent_id?: string;
  46. }
  47. export interface IOperatorNode {
  48. component_name: string;
  49. params: Record<string, unknown>;
  50. }
  51. export declare interface IFlow {
  52. avatar?: string;
  53. canvas_type: null;
  54. create_date: string;
  55. create_time: number;
  56. description: null;
  57. dsl: DSL;
  58. id: string;
  59. title: string;
  60. update_date: string;
  61. update_time: number;
  62. user_id: string;
  63. permission: string;
  64. nickname: string;
  65. }
  66. export interface IFlowTemplate {
  67. avatar: string;
  68. canvas_type: string;
  69. create_date: string;
  70. create_time: number;
  71. description: string;
  72. dsl: DSL;
  73. id: string;
  74. title: string;
  75. update_date: string;
  76. update_time: number;
  77. }
  78. export interface IGenerateForm {
  79. max_tokens?: number;
  80. temperature?: number;
  81. top_p?: number;
  82. presence_penalty?: number;
  83. frequency_penalty?: number;
  84. cite?: boolean;
  85. prompt: number;
  86. llm_id: string;
  87. parameters: { key: string; component_id: string };
  88. }
  89. export interface ICategorizeForm extends IGenerateForm {
  90. category_description: ICategorizeItemResult;
  91. }
  92. export interface IRelevantForm extends IGenerateForm {
  93. yes: string;
  94. no: string;
  95. }
  96. export interface ISwitchItem {
  97. cpn_id: string;
  98. operator: string;
  99. value: string;
  100. }
  101. export interface ISwitchForm {
  102. conditions: ISwitchCondition[];
  103. end_cpn_id: string;
  104. no: string;
  105. }
  106. export interface IBeginForm {
  107. prologue?: string;
  108. }
  109. export interface IRetrievalForm {
  110. similarity_threshold?: number;
  111. keywords_similarity_weight?: number;
  112. top_n?: number;
  113. top_k?: number;
  114. rerank_id?: string;
  115. empty_response?: string;
  116. kb_ids: string[];
  117. }
  118. export interface ICodeForm {
  119. arguments: Record<string, string>;
  120. lang: string;
  121. script?: string;
  122. outputs: Record<string, { value: string; type: string }>;
  123. }
  124. export interface IAgentForm {
  125. sys_prompt: string;
  126. prompts: Array<{
  127. role: string;
  128. content: string;
  129. }>;
  130. max_retries: number;
  131. delay_after_error: number;
  132. visual_files_var: string;
  133. max_rounds: number;
  134. exception_method: Nullable<'comment' | 'go'>;
  135. exception_comment: any;
  136. exception_goto: any;
  137. tools: Array<{
  138. component_name: string;
  139. params: Record<string, any>;
  140. }>;
  141. outputs: {
  142. structured_output: Record<string, Record<string, any>>;
  143. content: Record<string, any>;
  144. };
  145. }
  146. export type BaseNodeData<TForm extends any> = {
  147. label: string; // operator type
  148. name: string; // operator name
  149. color?: string;
  150. form?: TForm;
  151. };
  152. export type BaseNode<T = any> = Node<BaseNodeData<T>>;
  153. export type IBeginNode = BaseNode<IBeginForm>;
  154. export type IRetrievalNode = BaseNode<IRetrievalForm>;
  155. export type IGenerateNode = BaseNode<IGenerateForm>;
  156. export type ICategorizeNode = BaseNode<ICategorizeForm>;
  157. export type ISwitchNode = BaseNode<ISwitchForm>;
  158. export type IRagNode = BaseNode;
  159. export type IRelevantNode = BaseNode;
  160. export type ILogicNode = BaseNode;
  161. export type INoteNode = BaseNode;
  162. export type IMessageNode = BaseNode;
  163. export type IRewriteNode = BaseNode;
  164. export type IInvokeNode = BaseNode;
  165. export type ITemplateNode = BaseNode;
  166. export type IEmailNode = BaseNode;
  167. export type IIterationNode = BaseNode;
  168. export type IIterationStartNode = BaseNode;
  169. export type IKeywordNode = BaseNode;
  170. export type ICodeNode = BaseNode<ICodeForm>;
  171. export type IAgentNode = BaseNode;
  172. export type IToolNode = BaseNode<IAgentForm>;
  173. export type RAGFlowNodeType =
  174. | IBeginNode
  175. | IRetrievalNode
  176. | IGenerateNode
  177. | ICategorizeNode
  178. | ISwitchNode
  179. | IRagNode
  180. | IRelevantNode
  181. | ILogicNode
  182. | INoteNode
  183. | IMessageNode
  184. | IRewriteNode
  185. | IInvokeNode
  186. | ITemplateNode
  187. | IEmailNode
  188. | IIterationNode
  189. | IIterationStartNode
  190. | IKeywordNode;
  191. export interface IGraph {
  192. nodes: RAGFlowNodeType[];
  193. edges: Edge[];
  194. }
  195. export interface ITraceData {
  196. component_id: string;
  197. trace: Array<Record<string, any>>;
  198. }