mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-10-04 01:40:12 +02:00
fix: patch api key not persisting when setting LLM/Embedder (#458)
This commit is contained in:
parent
ecfd146891
commit
65c7c0a518
@ -91,7 +91,11 @@ function LocalAIModelSelection({ settings, apiKey = null, basePath = null }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const { models } = await System.customModels("localai", apiKey, basePath);
|
const { models } = await System.customModels(
|
||||||
|
"localai",
|
||||||
|
typeof apiKey === "boolean" ? null : apiKey,
|
||||||
|
basePath
|
||||||
|
);
|
||||||
setCustomModels(models || []);
|
setCustomModels(models || []);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,11 @@ function LocalAIModelSelection({ settings, basePath = null, apiKey = null }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const { models } = await System.customModels("localai", apiKey, basePath);
|
const { models } = await System.customModels(
|
||||||
|
"localai",
|
||||||
|
typeof apiKey === "boolean" ? null : apiKey,
|
||||||
|
basePath
|
||||||
|
);
|
||||||
setCustomModels(models || []);
|
setCustomModels(models || []);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,6 @@ import System from "@/models/system";
|
|||||||
export default function OpenAiOptions({ settings }) {
|
export default function OpenAiOptions({ settings }) {
|
||||||
const [inputValue, setInputValue] = useState(settings?.OpenAiKey);
|
const [inputValue, setInputValue] = useState(settings?.OpenAiKey);
|
||||||
const [openAIKey, setOpenAIKey] = useState(settings?.OpenAiKey);
|
const [openAIKey, setOpenAIKey] = useState(settings?.OpenAiKey);
|
||||||
function updateOpenAiKey() {
|
|
||||||
setOpenAIKey(inputValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -24,7 +21,7 @@ export default function OpenAiOptions({ settings }) {
|
|||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
spellCheck={false}
|
spellCheck={false}
|
||||||
onChange={(e) => setInputValue(e.target.value)}
|
onChange={(e) => setInputValue(e.target.value)}
|
||||||
onBlur={updateOpenAiKey}
|
onBlur={() => setOpenAIKey(inputValue)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<OpenAIModelSelection settings={settings} apiKey={openAIKey} />
|
<OpenAIModelSelection settings={settings} apiKey={openAIKey} />
|
||||||
|
@ -34,6 +34,8 @@ async function openAiModels(apiKey = null) {
|
|||||||
(model) => !model.owned_by.includes("openai") && model.owned_by !== "system"
|
(model) => !model.owned_by.includes("openai") && model.owned_by !== "system"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Api Key was successful so lets save it for future uses
|
||||||
|
if (models.length > 0 && !!apiKey) process.env.OPEN_AI_KEY = apiKey;
|
||||||
return { models, error: null };
|
return { models, error: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +43,7 @@ async function localAIModels(basePath = null, apiKey = null) {
|
|||||||
const { Configuration, OpenAIApi } = require("openai");
|
const { Configuration, OpenAIApi } = require("openai");
|
||||||
const config = new Configuration({
|
const config = new Configuration({
|
||||||
basePath,
|
basePath,
|
||||||
...(!!apiKey ? { apiKey } : {}),
|
apiKey: apiKey || process.env.LOCAL_AI_API_KEY,
|
||||||
});
|
});
|
||||||
const openai = new OpenAIApi(config);
|
const openai = new OpenAIApi(config);
|
||||||
const models = await openai
|
const models = await openai
|
||||||
@ -52,6 +54,8 @@ async function localAIModels(basePath = null, apiKey = null) {
|
|||||||
return [];
|
return [];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Api Key was successful so lets save it for future uses
|
||||||
|
if (models.length > 0 && !!apiKey) process.env.LOCAL_AI_API_KEY = apiKey;
|
||||||
return { models, error: null };
|
return { models, error: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user