agent-setting-button.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React, { useState } from 'react'
  4. import { useTranslation } from 'react-i18next'
  5. import AgentSetting from './agent/agent-setting'
  6. import Button from '@/app/components/base/button'
  7. import { Settings01 } from '@/app/components/base/icons/src/vender/line/general'
  8. import type { AgentConfig } from '@/models/debug'
  9. type Props = {
  10. isFunctionCall: boolean
  11. isChatModel: boolean
  12. agentConfig?: AgentConfig
  13. onAgentSettingChange: (payload: AgentConfig) => void
  14. }
  15. const AgentSettingButton: FC<Props> = ({
  16. onAgentSettingChange,
  17. isFunctionCall,
  18. isChatModel,
  19. agentConfig,
  20. }) => {
  21. const { t } = useTranslation()
  22. const [isShowAgentSetting, setIsShowAgentSetting] = useState(false)
  23. return (
  24. <>
  25. <Button onClick={() => setIsShowAgentSetting(true)} className='shrink-0 mr-2'>
  26. <Settings01 className='mr-1 w-4 h-4 text-gray-500' />
  27. {t('appDebug.agent.setting.name')}
  28. </Button>
  29. {isShowAgentSetting && (
  30. <AgentSetting
  31. isFunctionCall={isFunctionCall}
  32. payload={agentConfig as AgentConfig}
  33. isChatModel={isChatModel}
  34. onSave={(payloadNew) => {
  35. onAgentSettingChange(payloadNew)
  36. setIsShowAgentSetting(false)
  37. }}
  38. onCancel={() => setIsShowAgentSetting(false)}
  39. />
  40. )}
  41. </>
  42. )
  43. }
  44. export default React.memo(AgentSettingButton)