index.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import { useTranslation } from 'react-i18next'
  5. import type { RetrievalConfig } from '@/types/app'
  6. import { RETRIEVE_METHOD } from '@/types/app'
  7. import RadioCard from '@/app/components/base/radio-card'
  8. import { HighPriority } from '@/app/components/base/icons/src/vender/solid/arrows'
  9. import { PatternRecognition, Semantic } from '@/app/components/base/icons/src/vender/solid/development'
  10. import { FileSearch02 } from '@/app/components/base/icons/src/vender/solid/files'
  11. type Props = {
  12. value: RetrievalConfig
  13. }
  14. export const getIcon = (type: RETRIEVE_METHOD) => {
  15. return ({
  16. [RETRIEVE_METHOD.semantic]: Semantic,
  17. [RETRIEVE_METHOD.fullText]: FileSearch02,
  18. [RETRIEVE_METHOD.hybrid]: PatternRecognition,
  19. [RETRIEVE_METHOD.invertedIndex]: HighPriority,
  20. })[type] || FileSearch02
  21. }
  22. const EconomicalRetrievalMethodConfig: FC<Props> = ({
  23. // type,
  24. value,
  25. }) => {
  26. const { t } = useTranslation()
  27. const type = value.search_method
  28. const Icon = getIcon(type)
  29. return (
  30. <div className='space-y-2'>
  31. <RadioCard
  32. icon={<Icon className='w-4 h-4 text-[#7839EE]' />}
  33. title={t(`dataset.retrieval.${type}.title`)}
  34. description={t(`dataset.retrieval.${type}.description`)}
  35. noRadio
  36. chosenConfigWrapClassName='!pb-3'
  37. chosenConfig={
  38. <div className='flex flex-wrap leading-[18px] text-xs font-normal'>
  39. {value.reranking_model.reranking_model_name && (
  40. <div className='mr-8 flex space-x-1'>
  41. <div className='text-gray-500'>{t('common.modelProvider.rerankModel.key')}</div>
  42. <div className='font-medium text-gray-800'>{value.reranking_model.reranking_model_name}</div>
  43. </div>
  44. )}
  45. <div className='mr-8 flex space-x-1'>
  46. <div className='text-gray-500'>{t('appDebug.datasetConfig.top_k')}</div>
  47. <div className='font-medium text-gray-800'>{value.top_k}</div>
  48. </div>
  49. <div className='mr-8 flex space-x-1'>
  50. <div className='text-gray-500'>{t('appDebug.datasetConfig.score_threshold')}</div>
  51. <div className='font-medium text-gray-800'>{value.score_threshold}</div>
  52. </div>
  53. </div>
  54. }
  55. />
  56. </div>
  57. )
  58. }
  59. export default React.memo(EconomicalRetrievalMethodConfig)