node.tsx 989 B

1234567891011121314151617181920212223242526272829303132333435
  1. import type { FC } from 'react'
  2. import React from 'react'
  3. import type { LLMNodeType } from './types'
  4. import {
  5. useTextGenerationCurrentProviderAndModelAndModelList,
  6. } from '@/app/components/header/account-setting/model-provider-page/hooks'
  7. import ModelSelector from '@/app/components/header/account-setting/model-provider-page/model-selector'
  8. import type { NodeProps } from '@/app/components/workflow/types'
  9. const Node: FC<NodeProps<LLMNodeType>> = ({
  10. data,
  11. }) => {
  12. const { provider, name: modelId } = data.model || {}
  13. const {
  14. textGenerationModelList,
  15. } = useTextGenerationCurrentProviderAndModelAndModelList()
  16. const hasSetModel = provider && modelId
  17. if (!hasSetModel)
  18. return null
  19. return (
  20. <div className='mb-1 px-3 py-1'>
  21. {hasSetModel && (
  22. <ModelSelector
  23. defaultModel={{ provider, model: modelId }}
  24. modelList={textGenerationModelList}
  25. readonly
  26. />
  27. )}
  28. </div>
  29. )
  30. }
  31. export default React.memo(Node)