|
|
|
|
@ -1,6 +1,10 @@
|
|
|
|
|
'use client'
|
|
|
|
|
import type { FC } from 'react'
|
|
|
|
|
import React, { useCallback, useEffect, useState } from 'react'
|
|
|
|
|
import {
|
|
|
|
|
RiArrowDownDoubleLine,
|
|
|
|
|
RiEqualizer2Line,
|
|
|
|
|
} from '@remixicon/react'
|
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
|
import { usePathname } from 'next/navigation'
|
|
|
|
|
import { useBoolean } from 'ahooks'
|
|
|
|
|
@ -8,7 +12,6 @@ import type { LangFuseConfig, LangSmithConfig } from './type'
|
|
|
|
|
import { TracingProvider } from './type'
|
|
|
|
|
import TracingIcon from './tracing-icon'
|
|
|
|
|
import ConfigButton from './config-button'
|
|
|
|
|
import cn from '@/utils/classnames'
|
|
|
|
|
import { LangfuseIcon, LangsmithIcon } from '@/app/components/base/icons/src/public/tracing'
|
|
|
|
|
import Indicator from '@/app/components/header/indicator'
|
|
|
|
|
import { fetchTracingConfig as doFetchTracingConfig, fetchTracingStatus, updateTracingStatus } from '@/service/apps'
|
|
|
|
|
@ -16,6 +19,8 @@ import type { TracingStatus } from '@/models/app'
|
|
|
|
|
import Toast from '@/app/components/base/toast'
|
|
|
|
|
import { useAppContext } from '@/context/app-context'
|
|
|
|
|
import Loading from '@/app/components/base/loading'
|
|
|
|
|
import Divider from '@/app/components/base/divider'
|
|
|
|
|
import cn from '@/utils/classnames'
|
|
|
|
|
|
|
|
|
|
const I18N_PREFIX = 'app.tracing'
|
|
|
|
|
|
|
|
|
|
@ -27,7 +32,7 @@ const Title = ({
|
|
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className={cn(className, 'flex items-center text-lg font-semibold text-gray-900')}>
|
|
|
|
|
<div className={cn('flex items-center system-xl-semibold text-text-primary', className)}>
|
|
|
|
|
{t('common.appMenus.overview')}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
@ -135,43 +140,55 @@ const Panel: FC = () => {
|
|
|
|
|
return (
|
|
|
|
|
<div className={cn('mb-3 flex justify-between items-center')}>
|
|
|
|
|
<Title className='h-[41px]' />
|
|
|
|
|
<div className='flex items-center p-2 rounded-xl border-[0.5px] border-gray-200 shadow-xs cursor-pointer hover:bg-gray-100' onClick={showPopup}>
|
|
|
|
|
{!inUseTracingProvider
|
|
|
|
|
? <>
|
|
|
|
|
<TracingIcon size='md' className='mr-2' />
|
|
|
|
|
<div className='leading-5 text-sm font-semibold text-gray-700'>{t(`${I18N_PREFIX}.title`)}</div>
|
|
|
|
|
</>
|
|
|
|
|
: <InUseProviderIcon className='ml-1 h-4' />}
|
|
|
|
|
|
|
|
|
|
{hasConfiguredTracing && (
|
|
|
|
|
<div className='ml-4 mr-1 flex items-center'>
|
|
|
|
|
<Indicator color={enabled ? 'green' : 'gray'} />
|
|
|
|
|
<div className='ml-1.5 text-xs font-semibold text-gray-500 uppercase'>
|
|
|
|
|
{t(`${I18N_PREFIX}.${enabled ? 'enabled' : 'disabled'}`)}
|
|
|
|
|
<div
|
|
|
|
|
className={cn(
|
|
|
|
|
'flex items-center p-2 rounded-xl bg-background-default-dodge border-t border-l-[0.5px] border-effects-highlight shadow-xs cursor-pointer hover:bg-background-default-lighter hover:border-effects-highlight-lightmode-off',
|
|
|
|
|
controlShowPopup && 'bg-background-default-lighter border-effects-highlight-lightmode-off',
|
|
|
|
|
)}
|
|
|
|
|
onClick={showPopup}
|
|
|
|
|
>
|
|
|
|
|
{!inUseTracingProvider && (
|
|
|
|
|
<>
|
|
|
|
|
<TracingIcon size='md' />
|
|
|
|
|
<div className='mx-2 system-sm-semibold text-text-secondary'>{t(`${I18N_PREFIX}.title`)}</div>
|
|
|
|
|
<div className='p-1 rounded-md'>
|
|
|
|
|
<RiEqualizer2Line className='w-4 h-4 text-text-tertiary' />
|
|
|
|
|
</div>
|
|
|
|
|
<Divider type='vertical' className='h-3.5' />
|
|
|
|
|
<div className='p-1 rounded-md'>
|
|
|
|
|
<RiArrowDownDoubleLine className='w-4 h-4 text-text-tertiary' />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{hasConfiguredTracing && (
|
|
|
|
|
<div className='ml-2 w-px h-3.5 bg-gray-200'></div>
|
|
|
|
|
<>
|
|
|
|
|
<div className='ml-4 mr-1 flex items-center'>
|
|
|
|
|
<Indicator color={enabled ? 'green' : 'gray'} />
|
|
|
|
|
<div className='ml-1.5 system-xs-semibold-uppercase text-text-tertiary'>
|
|
|
|
|
{t(`${I18N_PREFIX}.${enabled ? 'enabled' : 'disabled'}`)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<InUseProviderIcon className='ml-1 h-4' />
|
|
|
|
|
<Divider type='vertical' className='h-3.5' />
|
|
|
|
|
<div className='flex items-center' onClick={e => e.stopPropagation()}>
|
|
|
|
|
<ConfigButton
|
|
|
|
|
appId={appId}
|
|
|
|
|
readOnly={readOnly}
|
|
|
|
|
hasConfigured
|
|
|
|
|
className='ml-2'
|
|
|
|
|
enabled={enabled}
|
|
|
|
|
onStatusChange={handleTracingEnabledChange}
|
|
|
|
|
chosenProvider={inUseTracingProvider}
|
|
|
|
|
onChooseProvider={handleChooseProvider}
|
|
|
|
|
langSmithConfig={langSmithConfig}
|
|
|
|
|
langFuseConfig={langFuseConfig}
|
|
|
|
|
onConfigUpdated={handleTracingConfigUpdated}
|
|
|
|
|
onConfigRemoved={handleTracingConfigRemoved}
|
|
|
|
|
controlShowPopup={controlShowPopup}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
<div className='flex items-center' onClick={e => e.stopPropagation()}>
|
|
|
|
|
<ConfigButton
|
|
|
|
|
appId={appId}
|
|
|
|
|
readOnly={readOnly}
|
|
|
|
|
hasConfigured
|
|
|
|
|
className='ml-2'
|
|
|
|
|
enabled={enabled}
|
|
|
|
|
onStatusChange={handleTracingEnabledChange}
|
|
|
|
|
chosenProvider={inUseTracingProvider}
|
|
|
|
|
onChooseProvider={handleChooseProvider}
|
|
|
|
|
langSmithConfig={langSmithConfig}
|
|
|
|
|
langFuseConfig={langFuseConfig}
|
|
|
|
|
onConfigUpdated={handleTracingConfigUpdated}
|
|
|
|
|
onConfigRemoved={handleTracingConfigRemoved}
|
|
|
|
|
controlShowPopup={controlShowPopup}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
|