| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  | import type { FC } from 'react' | 
					
						
							|  |  |  | import React from 'react' | 
					
						
							|  |  |  | import type { ToolNodeType } from './types' | 
					
						
							|  |  |  | import type { NodeProps } from '@/app/components/workflow/types' | 
					
						
							| 
									
										
										
										
											2025-02-17 17:05:13 +08:00
										 |  |  | import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations' | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | const Node: FC<NodeProps<ToolNodeType>> = ({ | 
					
						
							|  |  |  |   data, | 
					
						
							|  |  |  | }) => { | 
					
						
							| 
									
										
										
										
											2025-03-26 21:17:04 +08:00
										 |  |  |   const { tool_configurations, paramSchemas } = data | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |   const toolConfigs = Object.keys(tool_configurations || {}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!toolConfigs.length) | 
					
						
							|  |  |  |     return null | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <div className='mb-1 px-3 py-1'> | 
					
						
							|  |  |  |       <div className='space-y-0.5'> | 
					
						
							|  |  |  |         {toolConfigs.map((key, index) => ( | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |           <div key={index} className='flex h-6 items-center justify-between space-x-1 rounded-md  bg-gray-100 px-1 text-xs font-normal text-gray-700'> | 
					
						
							|  |  |  |             <div title={key} className='max-w-[100px] shrink-0 truncate text-xs font-medium uppercase text-gray-500'> | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |               {key} | 
					
						
							|  |  |  |             </div> | 
					
						
							| 
									
										
										
										
											2025-02-17 17:05:13 +08:00
										 |  |  |             {typeof tool_configurations[key] === 'string' && ( | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |               <div title={tool_configurations[key]} className='w-0 shrink-0 grow truncate text-right text-xs font-normal text-gray-700'> | 
					
						
							| 
									
										
										
										
											2025-03-26 21:17:04 +08:00
										 |  |  |                 {paramSchemas?.find(i => i.name === key)?.type === FormTypeEnum.secretInput ? '********' : tool_configurations[key]} | 
					
						
							|  |  |  |               </div> | 
					
						
							|  |  |  |             )} | 
					
						
							|  |  |  |             {typeof tool_configurations[key] === 'number' && ( | 
					
						
							|  |  |  |               <div title={tool_configurations[key].toString()} className='w-0 shrink-0 grow truncate text-right text-xs font-normal text-gray-700'> | 
					
						
							| 
									
										
										
										
											2025-02-17 17:05:13 +08:00
										 |  |  |                 {tool_configurations[key]} | 
					
						
							|  |  |  |               </div> | 
					
						
							|  |  |  |             )} | 
					
						
							|  |  |  |             {typeof tool_configurations[key] !== 'string' && tool_configurations[key]?.type === FormTypeEnum.modelSelector && ( | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |               <div title={tool_configurations[key].model} className='w-0 shrink-0 grow truncate text-right text-xs font-normal text-gray-700'> | 
					
						
							| 
									
										
										
										
											2025-02-17 17:05:13 +08:00
										 |  |  |                 {tool_configurations[key].model} | 
					
						
							|  |  |  |               </div> | 
					
						
							|  |  |  |             )} | 
					
						
							|  |  |  |             {/* {typeof tool_configurations[key] !== 'string' && tool_configurations[key]?.type === FormTypeEnum.appSelector && ( | 
					
						
							|  |  |  |               <div title={tool_configurations[key].app_id} className='grow w-0 shrink-0 truncate text-right text-xs font-normal text-gray-700'> | 
					
						
							|  |  |  |                 {tool_configurations[key].app_id} | 
					
						
							|  |  |  |               </div> | 
					
						
							|  |  |  |             )} */} | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |           </div> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ))} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       </div> | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default React.memo(Node) |