@@ -2,7 +2,7 @@ import { useState } from "react";
22import { Icon } from "@iconify/react" ;
33import { Modal } from "../../../components/modal" ;
44import { SettingsSectionContainer , SettingsSectionTitle } from "./components" ;
5- import { Button , Tooltip } from "@heroui/react" ;
5+ import { Accordion , AccordionItem , Button , Tooltip } from "@heroui/react" ;
66import { useSettingStore } from "../../../stores/setting-store" ;
77
88export const ApiKeySettings = ( ) => {
@@ -48,7 +48,7 @@ export const ApiKeySettings = () => {
4848 onOpenChange = { ( isOpen ) => setIsShowModal ( isOpen ) }
4949 content = {
5050 < div className = "flex flex-col h-[80vh] gap-4 p-4 overflow-y-auto" >
51- < CustomModelSection key = { "" } isNew onChange = { handleCustomModelChange } />
51+ < CustomModelSection key = { "new_custom_model " } isNew onChange = { handleCustomModelChange } />
5252 { Array . from ( settings ?. customModels || [ ] ) . map ( ( m ) => (
5353 < >
5454 < hr > </ hr >
@@ -120,7 +120,7 @@ const CustomModelSection = ({ isNew, onChange, model: customModel }: CustomModel
120120 const [ isApiKeyValid , setIsApiKeyValid ] = useState ( true ) ;
121121
122122 const borderedInputClassName = "rnd-cancel px-2 py-1 border !border-gray-200 dark:!border-default-200 rounded-md" ;
123- const baseClassName = "bg-transparent p-1 focus:outline-none disabled:opacity-70 disabled:cursor-not-allowed " ;
123+ const baseClassName = "bg-transparent p-1 focus:outline-none disabled:opacity-70" ;
124124 const modelNameInputClassName = `${ baseClassName } ${ isEditing || isNew ? borderedInputClassName : "" } text-sm text-default-900 font-medium flex-1 truncate mr-1` ;
125125 const labelClassName = `${ baseClassName } text-xs text-default-900 w-auto` ;
126126 const detailInputClassName = `${ baseClassName } ${ isEditing || isNew ? borderedInputClassName : "" } flex-1 noselect focus:outline-none text-xs text-default-700 placeholder:text-default-400` ;
@@ -260,49 +260,72 @@ const CustomModelSection = ({ isNew, onChange, model: customModel }: CustomModel
260260 />
261261 </ div >
262262
263- { /* <div className="flex flex-row">
264- <label className={labelClassName}>Context Window</label>
265- <input
266- className={detailInputClassName}
267- value={String(contextWindow)}
268- type="text"
269- disabled={!isEditing}
270- onChange={(e) => setContextWindow(e.target.valueAsNumber)}
271- />
272- </div>
263+ < Accordion className = "mt-2 px-0" variant = "light" selectionMode = "multiple" >
264+ < AccordionItem
265+ key = "optional-fields"
266+ aria-label = "More"
267+ title = { < span className = "text-xs text-default-900" > { isNew ? "Optional Fields" : "More" } </ span > }
268+ classNames = { {
269+ trigger : "px-1 py-0 min-h-0" ,
270+ content : "pt-1 pb-1" ,
271+ } }
272+ >
273+ < div className = "flex flex-col gap-1" >
274+ < div className = "flex flex-row" >
275+ < label className = { labelClassName } > Context Window</ label >
276+ < input
277+ className = { detailInputClassName }
278+ value = { String ( contextWindow ) }
279+ type = "number"
280+ min = { 0 }
281+ step = "1"
282+ disabled = { ! isEditing }
283+ onChange = { ( e ) => setContextWindow ( e . target . value === "" ? 0 : Math . trunc ( Number ( e . target . value ) ) ) }
284+ />
285+ </ div >
273286
274- <div className="flex flex-row">
275- <label className={labelClassName}>Max Output</label>
276- <input
277- className={detailInputClassName}
278- value={String(maxOutput)}
279- type="text"
280- disabled={!isEditing}
281- onChange={(e) => setMaxOutput(e.target.valueAsNumber)}
282- />
283- </div>
287+ < div className = "flex flex-row" >
288+ < label className = { labelClassName } > Max Output</ label >
289+ < input
290+ className = { detailInputClassName }
291+ value = { String ( maxOutput ) }
292+ type = "number"
293+ min = { 0 }
294+ step = "1"
295+ disabled = { ! isEditing }
296+ onChange = { ( e ) => setMaxOutput ( e . target . value === "" ? 0 : Math . trunc ( Number ( e . target . value ) ) ) }
297+ />
298+ </ div >
284299
285- <div className="flex flex-row">
286- <label className={labelClassName}>Input Price</label>
287- <input
288- className={detailInputClassName}
289- value={String(inputPrice)}
290- type="text"
291- disabled={!isEditing}
292- onChange={(e) => setInputPrice(e.target.valueAsNumber)}
293- />
294- </div>
300+ < div className = "flex flex-row" >
301+ < label className = { labelClassName } > Input Price</ label >
302+ < input
303+ className = { detailInputClassName }
304+ value = { String ( inputPrice ) }
305+ type = "number"
306+ min = { 0 }
307+ step = "1"
308+ disabled = { ! isEditing }
309+ onChange = { ( e ) => setInputPrice ( e . target . value === "" ? 0 : Math . trunc ( Number ( e . target . value ) ) ) }
310+ />
311+ </ div >
295312
296- <div className="flex flex-row">
297- <label className={labelClassName}>Output Price</label>
298- <input
299- className={detailInputClassName}
300- value={String(outputPrice)}
301- type="text"
302- disabled={!isEditing}
303- onChange={(e) => setOutputPrice(e.target.valueAsNumber)}
304- />
305- </div> */ }
313+ < div className = "flex flex-row" >
314+ < label className = { labelClassName } > Output Price</ label >
315+ < input
316+ className = { detailInputClassName }
317+ value = { String ( outputPrice ) }
318+ type = "number"
319+ min = { 0 }
320+ step = "1"
321+ pattern = "[0-9]*"
322+ disabled = { ! isEditing }
323+ onChange = { ( e ) => setOutputPrice ( e . target . value === "" ? 0 : Math . trunc ( Number ( e . target . value ) ) ) }
324+ />
325+ </ div >
326+ </ div >
327+ </ AccordionItem >
328+ </ Accordion >
306329 </ div >
307330 ) ;
308331} ;
0 commit comments