@@ -6,11 +6,12 @@ import { rgba } from 'polished';
6
6
import { memo } from 'react' ;
7
7
import { useTranslation } from 'react-i18next' ;
8
8
import { Center , Flexbox } from 'react-layout-kit' ;
9
- import ModelIcon from 'src/components/ModelIcon' ;
10
- import ModelProviderIcon from 'src/components/ModelProviderIcon' ;
11
9
12
10
import { ChatModelCard } from '@/types/llm' ;
13
11
12
+ import ModelIcon from '../ModelIcon' ;
13
+ import ModelProviderIcon from '../ModelProviderIcon' ;
14
+
14
15
const useStyles = createStyles ( ( { css, token } ) => ( {
15
16
custom : css `
16
17
width : 36px ;
@@ -56,69 +57,79 @@ const useStyles = createStyles(({ css, token }) => ({
56
57
` ,
57
58
} ) ) ;
58
59
60
+ interface ModelInfoTagsProps extends ChatModelCard {
61
+ directionReverse ?: boolean ;
62
+ placement ?: 'top' | 'right' ;
63
+ }
64
+ export const ModelInfoTags = memo < ModelInfoTagsProps > (
65
+ ( { directionReverse, placement = 'right' , ...model } ) => {
66
+ const { t } = useTranslation ( 'common' ) ;
67
+ const { styles, cx } = useStyles ( ) ;
68
+
69
+ return (
70
+ < Flexbox direction = { directionReverse ? 'horizontal-reverse' : 'horizontal' } gap = { 4 } >
71
+ { model . files && (
72
+ < Tooltip placement = { placement } title = { t ( 'ModelSelect.featureTag.file' ) } >
73
+ < div className = { cx ( styles . tag , styles . tagGreen ) } >
74
+ < Icon icon = { LucidePaperclip } />
75
+ </ div >
76
+ </ Tooltip >
77
+ ) }
78
+ { model . vision && (
79
+ < Tooltip placement = { placement } title = { t ( 'ModelSelect.featureTag.vision' ) } >
80
+ < div className = { cx ( styles . tag , styles . tagGreen ) } >
81
+ < Icon icon = { LucideEye } />
82
+ </ div >
83
+ </ Tooltip >
84
+ ) }
85
+ { model . functionCall && (
86
+ < Tooltip
87
+ overlayStyle = { { maxWidth : 'unset' } }
88
+ placement = { placement }
89
+ title = { t ( 'ModelSelect.featureTag.functionCall' ) }
90
+ >
91
+ < div className = { cx ( styles . tag , styles . tagBlue ) } >
92
+ < Icon icon = { ToyBrick } />
93
+ </ div >
94
+ </ Tooltip >
95
+ ) }
96
+ { model . tokens && (
97
+ < Tooltip
98
+ overlayStyle = { { maxWidth : 'unset' } }
99
+ placement = { placement }
100
+ title = { t ( 'ModelSelect.featureTag.tokens' , {
101
+ tokens : numeral ( model . tokens ) . format ( '0,0' ) ,
102
+ } ) }
103
+ >
104
+ < Center className = { styles . token } > { Math . floor ( model . tokens / 1000 ) } K</ Center >
105
+ </ Tooltip >
106
+ ) }
107
+ { model . isCustom && (
108
+ < Tooltip
109
+ overlayStyle = { { maxWidth : 300 } }
110
+ placement = { placement }
111
+ title = { t ( 'ModelSelect.featureTag.custom' ) }
112
+ >
113
+ < Center className = { styles . custom } > DIY</ Center >
114
+ </ Tooltip >
115
+ ) }
116
+ </ Flexbox >
117
+ ) ;
118
+ } ,
119
+ ) ;
120
+
59
121
interface ModelItemRenderProps extends ChatModelCard {
60
122
showInfoTag ?: boolean ;
61
123
}
62
124
export const ModelItemRender = memo < ModelItemRenderProps > ( ( { showInfoTag = true , ...model } ) => {
63
- const { styles, cx } = useStyles ( ) ;
64
- const { t } = useTranslation ( 'common' ) ;
65
-
66
125
return (
67
126
< Flexbox align = { 'center' } gap = { 32 } horizontal justify = { 'space-between' } >
68
127
< Flexbox align = { 'center' } gap = { 8 } horizontal >
69
128
< ModelIcon model = { model . id } size = { 20 } />
70
129
{ model . displayName || model . id }
71
130
</ Flexbox >
72
131
73
- { showInfoTag && (
74
- < Flexbox gap = { 4 } horizontal >
75
- { model . files && (
76
- < Tooltip placement = { 'right' } title = { t ( 'ModelSelect.featureTag.file' ) } >
77
- < div className = { cx ( styles . tag , styles . tagGreen ) } >
78
- < Icon icon = { LucidePaperclip } />
79
- </ div >
80
- </ Tooltip >
81
- ) }
82
- { model . vision && (
83
- < Tooltip placement = { 'right' } title = { t ( 'ModelSelect.featureTag.vision' ) } >
84
- < div className = { cx ( styles . tag , styles . tagGreen ) } >
85
- < Icon icon = { LucideEye } />
86
- </ div >
87
- </ Tooltip >
88
- ) }
89
- { model . functionCall && (
90
- < Tooltip
91
- overlayStyle = { { maxWidth : 'unset' } }
92
- placement = { 'right' }
93
- title = { t ( 'ModelSelect.featureTag.functionCall' ) }
94
- >
95
- < div className = { cx ( styles . tag , styles . tagBlue ) } >
96
- < Icon icon = { ToyBrick } />
97
- </ div >
98
- </ Tooltip >
99
- ) }
100
- { model . tokens && (
101
- < Tooltip
102
- overlayStyle = { { maxWidth : 'unset' } }
103
- placement = { 'right' }
104
- title = { t ( 'ModelSelect.featureTag.tokens' , {
105
- tokens : numeral ( model . tokens ) . format ( '0,0' ) ,
106
- } ) }
107
- >
108
- < Center className = { styles . token } > { Math . floor ( model . tokens / 1000 ) } K</ Center >
109
- </ Tooltip >
110
- ) }
111
- { model . isCustom && (
112
- < Tooltip
113
- overlayStyle = { { maxWidth : 300 } }
114
- placement = { 'right' }
115
- title = { t ( 'ModelSelect.featureTag.custom' ) }
116
- >
117
- < Center className = { styles . custom } > DIY</ Center >
118
- </ Tooltip >
119
- ) }
120
- </ Flexbox >
121
- ) }
132
+ { showInfoTag && < ModelInfoTags { ...model } /> }
122
133
</ Flexbox >
123
134
) ;
124
135
} ) ;
0 commit comments