Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

2.1 KB
Raw Blame
import { cssVar, Divider, Flexbox } from '@lobehub/ui';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import urlJoin from 'url-join';

import { USAGE_DOCUMENTS } from '@/const/url';

import Statistic from '../../../../../components/Statistic';

const DEFAULT_DOC_URL = urlJoin(USAGE_DOCUMENTS, 'agents/model');

export interface ParameterItemProps {
  defaultValue: string | number;
  desc: string;
  docUrl?: string;
  range?: (string | number)[];
  type: string;
}

const formatNum = (num: string | number) => {
  return typeof num === 'number' ? num.toFixed(2) : num.toUpperCase();
};

const ParameterItem = memo<ParameterItemProps>(
  ({ docUrl = DEFAULT_DOC_URL, desc, type, defaultValue, range }) => {
    const { t } = useTranslation('discover');

    return (
      <Flexbox align={'flex-start'} gap={16}>
        <p style={{ color: cssVar.colorTextSecondary, margin: 0 }}>
          {desc}{' '}
          <a href={docUrl} rel="noreferrer" target="_blank">
            {t('models.parameterList.docs')}
          </a>
        </p>
        <Divider dashed />
        <Flexbox horizontal align={'center'} gap={16} style={{ paddingBottom: 8 }} wrap={'wrap'}>
          <Statistic
            gap={4}
            title={t('models.parameterList.type')}
            value={<code>{type.toUpperCase()}</code>}
            valuePlacement={'bottom'}
            valueStyle={{ fontSize: 14 }}
            width={100}
          />
          <Statistic
            gap={4}
            title={t('models.parameterList.defaultValue')}
            value={formatNum(defaultValue)}
            valuePlacement={'bottom'}
            valueStyle={{ fontSize: 14 }}
            width={100}
          />
          {range && (
            <Statistic
              gap={4}
              title={t('models.parameterList.range')}
              value={range.map((item) => (type === 'float' ? formatNum(item) : item)).join(' ~ ')}
              valuePlacement={'bottom'}
              valueStyle={{ fontSize: 14 }}
              width={100}
            />
          )}
        </Flexbox>
      </Flexbox>
    );
  },
);

export default ParameterItem;