fix: get OpenAI models only if OpenAI Enabled;timeout for query OpenAI models

This commit is contained in:
Liuzhch1 2024-09-10 19:22:05 +08:00
parent e510c8b11f
commit 26700ac4ac
2 changed files with 10 additions and 8 deletions

View File

@ -443,7 +443,7 @@ def get_available_models() -> list[dict]:
try:
response = requests.get(
"https://api.elevenlabs.io/v1/models", headers=headers
"https://api.elevenlabs.io/v1/models", headers=headers, timeout=5
)
response.raise_for_status()
models = response.json()

View File

@ -150,18 +150,20 @@
})()
]);
OPENAI_API_BASE_URLS.forEach(async (url, idx) => {
const res = await getOpenAIModels(localStorage.token, idx);
if (res.pipelines) {
pipelineUrls[url] = true;
}
});
const ollamaConfig = await getOllamaConfig(localStorage.token);
const openaiConfig = await getOpenAIConfig(localStorage.token);
ENABLE_OPENAI_API = openaiConfig.ENABLE_OPENAI_API;
ENABLE_OLLAMA_API = ollamaConfig.ENABLE_OLLAMA_API;
if (ENABLE_OPENAI_API) {
OPENAI_API_BASE_URLS.forEach(async (url, idx) => {
const res = await getOpenAIModels(localStorage.token, idx);
if (res.pipelines) {
pipelineUrls[url] = true;
}
});
}
}
});
</script>