node.tsx 981 B

12345678910111213141516171819202122232425262728293031
  1. import type { FC } from 'react'
  2. import React from 'react'
  3. import type { ParameterExtractorNodeType } 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<ParameterExtractorNodeType>> = ({
  10. data,
  11. }) => {
  12. const { provider, name: modelId } = data.model || {}
  13. const {
  14. textGenerationModelList,
  15. } = useTextGenerationCurrentProviderAndModelAndModelList()
  16. const hasSetModel = provider && modelId
  17. return (
  18. <div className='mb-1 px-3 py-1'>
  19. {hasSetModel && (
  20. <ModelSelector
  21. defaultModel={{ provider, model: modelId }}
  22. modelList={textGenerationModelList}
  23. readonly
  24. />
  25. )}
  26. </div>
  27. )
  28. }
  29. export default React.memo(Node)