diff --git a/src/renderer/components/Experiment/Eval/Eval.tsx b/src/renderer/components/Experiment/Eval/Eval.tsx index 0ae4075997a0f1607d421310371354c69b7008b6..8ea629d7b307c1fa71d01148d86e101e00c8c9e1 100644 --- a/src/renderer/components/Experiment/Eval/Eval.tsx +++ b/src/renderer/components/Experiment/Eval/Eval.tsx @@ -243,11 +243,8 @@ export default function Eval({ /* The way evals are defined right now, they need a unique name. This is a hack until we have a better solution */ - /* Adding a hack to not store the commercial_api_key in the evaluation name if there is one */ - const formJsonCopy = { ...formJson } - delete formJsonCopy.commercial_api_key; const nameOfThisEvaluation = - selectedPlugin + '_' + JSON.stringify(formJsonCopy); + selectedPlugin + '_' + JSON.stringify(formJson); addEvaluation(selectedPlugin, nameOfThisEvaluation, formJson); setOpen(false); }} diff --git a/src/renderer/components/TransformerLabSettings.tsx b/src/renderer/components/TransformerLabSettings.tsx index 970e669bfc8861a8eeb70fb99e5a5265565aed62..054da53480eb795ce73fd6a15c3056f8ae116440 100644 --- a/src/renderer/components/TransformerLabSettings.tsx +++ b/src/renderer/components/TransformerLabSettings.tsx @@ -24,7 +24,8 @@ import { EyeIcon, EyeOffIcon, RotateCcwIcon } from 'lucide-react'; const fetcher = (url) => fetch(url).then((res) => res.json()); -export default function TransformerLabSettings({}) { + +export default function TransformerLabSettings({ }) { const [showPassword, setShowPassword] = React.useState(false); const { data: hftoken, @@ -129,6 +130,45 @@ export default function TransformerLabSettings({}) { </FormControl> </> )}{' '} + <FormControl sx={{ maxWidth: '500px', mt: 2 }}> + <FormLabel>OpenAI API Key</FormLabel> + <Input name="openaiKey" type="password" /> + <Button + onClick={async () => { + const token = document.getElementsByName('openaiKey')[0].value; + await fetch(chatAPI.Endpoints.Config.Set('OPENAI_API_KEY', token)); + await fetch(chatAPI.Endpoints.Models.SetOpenAIKey()); + const response = await fetch(chatAPI.Endpoints.Models.CheckOpenAIAPIKey()); + const result = await response.json(); + if (result.message === "OK") { + alert("Successfully set OpenAI API Key"); + } + }} + + sx={{ marginTop: 1, width: '100px', alignSelf: 'flex-end' }} + > + Save + </Button> + </FormControl> + <FormControl sx={{ maxWidth: '500px', mt: 2 }}> + <FormLabel>Anthropic API Key</FormLabel> + <Input name="anthropicKey" type="password" /> + <Button + onClick={async () => { + const token = document.getElementsByName('anthropicKey')[0].value; + await fetch(chatAPI.Endpoints.Config.Set('ANTHROPIC_API_KEY', token)); + await fetch(chatAPI.Endpoints.Models.SetAnthropicKey()); + const response = await fetch(chatAPI.Endpoints.Models.CheckAnthropicAPIKey()); + const result = await response.json(); + if (result.message === "OK") { + alert("Successfully set Anthropic API Key"); + } + }} + sx={{ marginTop: 1, width: '100px', alignSelf: 'flex-end' }} + > + Save + </Button> + </FormControl> <Divider sx={{ mt: 2, mb: 2 }} />{' '} <Typography level="title-lg" marginBottom={2}> Application: diff --git a/src/renderer/lib/transformerlab-api-sdk.ts b/src/renderer/lib/transformerlab-api-sdk.ts index 43c37615bdc6735b4b14c556306d24cfe58f2e65..412ce21ec458e1e2f8a4ef7c757fc88e5d3b802b 100644 --- a/src/renderer/lib/transformerlab-api-sdk.ts +++ b/src/renderer/lib/transformerlab-api-sdk.ts @@ -1025,7 +1025,7 @@ Endpoints.Dataset = { Endpoints.Models = { LocalList: () => API_URL() + 'model/list', - CountDownloaded: () => API_URL() + 'model/count_downloaded', + CountDownloaded: () => API_URL() + 'model/count_downloaded', Gallery: () => API_URL() + 'model/gallery', GetPeftsForModel: () => API_URL() + 'model/pefts', UploadModelToHuggingFace: ( @@ -1063,6 +1063,10 @@ Endpoints.Models = { API_URL() + 'model/import_from_local_path?model_path=' + modelPath, HuggingFaceLogin: () => API_URL() + 'model/login_to_huggingface', Delete: (modelId: string) => API_URL() + 'model/delete?model_id=' + modelId, + SetOpenAIKey: () => API_URL() + 'model/set_openai_api_key', + SetAnthropicKey: () => API_URL() + 'model/set_anthropic_api_key', + CheckOpenAIAPIKey: () => API_URL() + 'model/check_openai_api_key', + CheckAnthropicAPIKey: () => API_URL() + 'model/check_anthropic_api_key', }; Endpoints.Plugins = { @@ -1249,9 +1253,9 @@ Endpoints.Experiment = { DeleteConversation: (experimentId: string, conversationId: string) => FULL_PATH( 'experiment/' + - experimentId + - '/conversations/delete?conversation_id=' + - conversationId + experimentId + + '/conversations/delete?conversation_id=' + + conversationId ), InstallPlugin: (experimentId: string, pluginId: string) => API_URL() + @@ -1276,10 +1280,10 @@ Endpoints.Experiment = { ) => FULL_PATH( 'experiment/' + - experimentId + - '/plugins/list?type=' + - type + - (filter ? '&filter=' + filter : '') + experimentId + + '/plugins/list?type=' + + type + + (filter ? '&filter=' + filter : '') ), ScriptListFiles: (experimentId: string, id: string) => API_URL() + 'experiment/' + experimentId + '/plugins/' + id + '/list_files', @@ -1553,16 +1557,16 @@ export async function activateWorker( try { response = await fetch( API_URL() + - 'server/worker_start?model_name=' + - model + - '&adaptor=' + - adaptorName + - '&engine=' + - engine + - '&experiment_id=' + - experimentId + - '¶meters=' + - paramsJSON + 'server/worker_start?model_name=' + + model + + '&adaptor=' + + adaptorName + + '&engine=' + + engine + + '&experiment_id=' + + experimentId + + '¶meters=' + + paramsJSON ); const result = await response.json(); return result;