diff --git a/src/simple-editor/ModelDeployment.tsx b/src/simple-editor/ModelDeployment.tsx index bf30f6a..ddd0e4d 100644 --- a/src/simple-editor/ModelDeployment.tsx +++ b/src/simple-editor/ModelDeployment.tsx @@ -6,11 +6,14 @@ import { } from '@mui/material'; interface ModelDeploymentProps { - value: string; - onChange: (value: string) => void; + value : string; + onChange: (value: string) => void; } -const ModelDeployment: React.FC = ({ value, onChange }) => { +const ModelDeployment: React.FC = ({ + value, onChange +}) => { + return ( diff --git a/src/simple-editor/ModelParameters.tsx b/src/simple-editor/ModelParameters.tsx index 86aebeb..3b34152 100644 --- a/src/simple-editor/ModelParameters.tsx +++ b/src/simple-editor/ModelParameters.tsx @@ -1,52 +1,120 @@ import React from 'react'; -import { TextField, Slider } from '@mui/material'; +import { + FormControl, InputLabel, Select, MenuItem, TextField, Slider +} from '@mui/material'; + +import modelsRaw from './models.json'; +const models = modelsRaw as { [ix : string ] : string[] }; interface ModelParametersProps { - modelName: string; - temperature: number; - maxOutputTokens: number; - onModelNameChange: (value: string) => void; - onTemperatureChange: (value: number) => void; - onMaxOutputTokensChange: (value: number) => void; + modelName: string; + temperature: number; + maxOutputTokens: number; + onModelNameChange: (value: string) => void; + onTemperatureChange: (value: number) => void; + onMaxOutputTokensChange: (value: number) => void; + modelDeployment : string; } const ModelParameters: React.FC = ({ - modelName, - temperature, - maxOutputTokens, - onModelNameChange, - onTemperatureChange, - onMaxOutputTokensChange, + modelName, + temperature, + modelDeployment, + maxOutputTokens, + onModelNameChange, + onTemperatureChange, + onMaxOutputTokensChange, }) => { - return ( -
- onModelNameChange(e.target.value)} - margin="normal" - /> -
-

Temperature: {temperature}

- onTemperatureChange(value as number)} - min={0} - max={1} - step={0.1} - /> -
- onMaxOutputTokensChange(parseInt(e.target.value))} - margin="normal" - /> -
- ); + + const availModels = models[modelDeployment]; + + const ModelList : React.FC<{ + modelName : string; + availModels : string[]; + onModelNameChange : (value: string) => void; + }> = ({ modelName, availModels, onModelNameChange}) => { + + const readOnly = (availModels.length == 0); + + if (availModels.length == 0) { + return ( + + + Model + + + + ); + + } + + return ( + + + Model + + + + + + ); + } + + return ( +
+ + + +
+

Temperature: {temperature}

+ onTemperatureChange(value as number) + } + min={0} + max={1} + step={0.1} + /> +
+ onMaxOutputTokensChange(parseInt(e.target.value)) + } + margin="normal" + /> +
+ ); }; export default ModelParameters; diff --git a/src/simple-editor/ParamsForm.tsx b/src/simple-editor/ParamsForm.tsx index 17b0910..081ce27 100644 --- a/src/simple-editor/ParamsForm.tsx +++ b/src/simple-editor/ParamsForm.tsx @@ -12,6 +12,9 @@ import ModelParameters from './ModelParameters'; import { useModelParamsStore } from './state/ModelParams'; import { useDeploymentStore } from './state/Deployment'; +import modelsRaw from './models.json'; +const models = modelsRaw as { [ix : string ] : string[] }; + interface ParamsFormProps { } @@ -79,6 +82,20 @@ const ParamsForm: React.FC = ({ const setMaxOutputTokens = useModelParamsStore((state) => state.setMaxOutputTokens); + useModelParamsStore.subscribe( + (n, o) => { + + if (n.modelDeployment == o.modelDeployment) return; + + if (n.modelName in models[n.modelDeployment]) return; + + if (models[n.modelDeployment].length == 0) + setModelName(""); + else + setModelName(models[n.modelDeployment][0]); + + } + ); return ( @@ -119,6 +136,7 @@ const ParamsForm: React.FC = ({ onModelNameChange={setModelName} onTemperatureChange={setTemperature} onMaxOutputTokensChange={setMaxOutputTokens} + modelDeployment={modelDeployment} /> diff --git a/src/simple-editor/models.json b/src/simple-editor/models.json index 80fea14..f16f94c 100644 --- a/src/simple-editor/models.json +++ b/src/simple-editor/models.json @@ -1,5 +1,5 @@ { - "anthropic": [ + "claude": [ "claude-3-5-sonnet-20240620", "claude-3-opus-20240229", "claude-3-sonnet-20240229", @@ -94,5 +94,9 @@ "gemini-flash-experimental", "gemini-pro-experimental", "gemini-experimental" + ], + "llamafile": [ + ], + "azure": [ ] -} \ No newline at end of file +}