1+ import { useMemo } from "react"
12import { VSCodeLink } from "@vscode/webview-ui-toolkit/react"
2- import { Fragment } from "react"
3+
4+ import { formatPrice } from "@/utils/formatPrice"
5+ import { cn } from "@/lib/utils"
36
47import { ModelInfo , geminiModels } from "../../../../src/shared/api"
8+
59import { ModelDescriptionMarkdown } from "./ModelDescriptionMarkdown"
6- import { formatPrice } from "../../utils/formatPrice"
10+
11+ type ModelInfoViewProps = {
12+ selectedModelId : string
13+ modelInfo : ModelInfo
14+ isDescriptionExpanded : boolean
15+ setIsDescriptionExpanded : ( isExpanded : boolean ) => void
16+ }
717
818export const ModelInfoView = ( {
919 selectedModelId,
1020 modelInfo,
1121 isDescriptionExpanded,
1222 setIsDescriptionExpanded,
13- } : {
14- selectedModelId : string
15- modelInfo : ModelInfo
16- isDescriptionExpanded : boolean
17- setIsDescriptionExpanded : ( isExpanded : boolean ) => void
18- } ) => {
19- const isGemini = Object . keys ( geminiModels ) . includes ( selectedModelId )
23+ } : ModelInfoViewProps ) => {
24+ const isGemini = useMemo ( ( ) => Object . keys ( geminiModels ) . includes ( selectedModelId ) , [ selectedModelId ] )
2025
2126 const infoItems = [
22- modelInfo . description && (
23- < ModelDescriptionMarkdown
24- key = "description"
25- markdown = { modelInfo . description }
26- isExpanded = { isDescriptionExpanded }
27- setIsExpanded = { setIsDescriptionExpanded }
28- />
29- ) ,
3027 < ModelInfoSupportsItem
3128 isSupported = { modelInfo . supportsImages ?? false }
3229 supportsLabel = "Supports images"
@@ -45,53 +42,59 @@ export const ModelInfoView = ({
4542 />
4643 ) ,
4744 modelInfo . maxTokens !== undefined && modelInfo . maxTokens > 0 && (
48- < span key = "maxTokens" >
49- < span style = { { fontWeight : 500 } } > Max output:</ span > { modelInfo . maxTokens ?. toLocaleString ( ) } tokens
50- </ span >
45+ < >
46+ < span className = "font-medium" > Max output:</ span > { modelInfo . maxTokens ?. toLocaleString ( ) } tokens
47+ </ >
5148 ) ,
5249 modelInfo . inputPrice !== undefined && modelInfo . inputPrice > 0 && (
53- < span key = "inputPrice" >
54- < span style = { { fontWeight : 500 } } > Input price:</ span > { formatPrice ( modelInfo . inputPrice ) } /million tokens
55- </ span >
50+ < >
51+ < span className = "font-medium" > Input price:</ span > { formatPrice ( modelInfo . inputPrice ) } / 1M tokens
52+ </ >
5653 ) ,
57- modelInfo . supportsPromptCache && modelInfo . cacheWritesPrice && (
58- < span key = "cacheWritesPrice" >
59- < span style = { { fontWeight : 500 } } > Cache writes price:</ span > { " " }
60- { formatPrice ( modelInfo . cacheWritesPrice || 0 ) } /million tokens
61- </ span >
54+ modelInfo . outputPrice !== undefined && modelInfo . outputPrice > 0 && (
55+ < >
56+ < span className = "font-medium" > Output price:</ span > { formatPrice ( modelInfo . outputPrice ) } / 1M tokens
57+ </ >
6258 ) ,
6359 modelInfo . supportsPromptCache && modelInfo . cacheReadsPrice && (
64- < span key = "cacheReadsPrice" >
65- < span style = { { fontWeight : 500 } } > Cache reads price:</ span > { " " }
66- { formatPrice ( modelInfo . cacheReadsPrice || 0 ) } /million tokens
67- </ span >
60+ < >
61+ < span className = "font-medium" > Cache reads price:</ span > { formatPrice ( modelInfo . cacheReadsPrice || 0 ) } /
62+ 1M tokens
63+ </ >
6864 ) ,
69- modelInfo . outputPrice !== undefined && modelInfo . outputPrice > 0 && (
70- < span key = "outputPrice" >
71- < span style = { { fontWeight : 500 } } > Output price:</ span > { formatPrice ( modelInfo . outputPrice ) } /million
72- tokens
73- </ span >
65+ modelInfo . supportsPromptCache && modelInfo . cacheWritesPrice && (
66+ < >
67+ < span className = "font-medium" > Cache writes price:</ span > { formatPrice ( modelInfo . cacheWritesPrice || 0 ) } { " " }
68+ / 1M tokens
69+ </ >
7470 ) ,
7571 isGemini && (
76- < span key = "geminiInfo" style = { { fontStyle : " italic" } } >
72+ < span className = " italic">
7773 * Free up to { selectedModelId && selectedModelId . includes ( "flash" ) ? "15" : "2" } requests per minute.
7874 After that, billing depends on prompt size.{ " " }
79- < VSCodeLink href = "https://ai.google.dev/pricing" style = { { display : "inline" , fontSize : "inherit" } } >
75+ < VSCodeLink href = "https://ai.google.dev/pricing" className = "text-sm" >
8076 For more info, see pricing details.
8177 </ VSCodeLink >
8278 </ span >
8379 ) ,
8480 ] . filter ( Boolean )
8581
8682 return (
87- < div style = { { fontSize : "12px" , marginTop : "2px" , color : "var(--vscode-descriptionForeground)" } } >
88- { infoItems . map ( ( item , index ) => (
89- < Fragment key = { index } >
90- { item }
91- { index < infoItems . length - 1 && < br /> }
92- </ Fragment >
93- ) ) }
94- </ div >
83+ < >
84+ { modelInfo . description && (
85+ < ModelDescriptionMarkdown
86+ key = "description"
87+ markdown = { modelInfo . description }
88+ isExpanded = { isDescriptionExpanded }
89+ setIsExpanded = { setIsDescriptionExpanded }
90+ />
91+ ) }
92+ < div className = "text-sm text-vscode-descriptionForeground" >
93+ { infoItems . map ( ( item , index ) => (
94+ < div key = { index } > { item } </ div >
95+ ) ) }
96+ </ div >
97+ </ >
9598 )
9699}
97100
@@ -104,21 +107,12 @@ const ModelInfoSupportsItem = ({
104107 supportsLabel : string
105108 doesNotSupportLabel : string
106109} ) => (
107- < span
108- style = { {
109- fontWeight : 500 ,
110- color : isSupported ? "var(--vscode-charts-green)" : "var(--vscode-errorForeground)" ,
111- } } >
112- < i
113- className = { `codicon codicon-${ isSupported ? "check" : "x" } ` }
114- style = { {
115- marginRight : 4 ,
116- marginBottom : isSupported ? 1 : - 1 ,
117- fontSize : isSupported ? 11 : 13 ,
118- fontWeight : 700 ,
119- display : "inline-block" ,
120- verticalAlign : "bottom" ,
121- } } > </ i >
110+ < div
111+ className = { cn (
112+ "flex items-center gap-1 font-medium" ,
113+ isSupported ? "text-vscode-charts-green" : "text-vscode-errorForeground" ,
114+ ) } >
115+ < span className = { cn ( "codicon" , isSupported ? "codicon-check" : "codicon-x" ) } />
122116 { isSupported ? supportsLabel : doesNotSupportLabel }
123- </ span >
117+ </ div >
124118)
0 commit comments