You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

agent-setting-button.tsx 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React, { useState } from 'react'
  4. import { useTranslation } from 'react-i18next'
  5. import { RiSettings2Line } from '@remixicon/react'
  6. import AgentSetting from './agent/agent-setting'
  7. import Button from '@/app/components/base/button'
  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='mr-2 shrink-0'>
  26. <RiSettings2Line className='mr-1 h-4 w-4 text-text-tertiary' />
  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)