fix: ollama version request when ollama api is disabled
This commit is contained in:
1 parent
1d6bbdf917
commit
d077b3dcdb
2 files changed
+9
-2
No files matched your search
@@ -274,12 +274,13 @@ async def get_ollama_tags(
|
||||
@app.get("/api/version")
|
||||
@app.get("/api/version/{url_idx}")
|
||||
async def get_ollama_versions(url_idx: Optional[int] = None):
|
||||
|
||||
if app.state.config.ENABLE_OLLAMA_API:
|
||||
if url_idx == None:
|
||||
|
||||
# returns lowest version
|
||||
tasks = [
|
||||
fetch_url(f"{url}/api/version") for url in app.state.config.OLLAMA_BASE_URLS
|
||||
fetch_url(f"{url}/api/version")
|
||||
for url in app.state.config.OLLAMA_BASE_URLS
|
||||
]
|
||||
responses = await asyncio.gather(*tasks)
|
||||
responses = list(filter(lambda x: x is not None, responses))
|
||||
@@ -322,6 +323,8 @@ async def get_ollama_versions(url_idx: Optional[int] = None):
|
||||
status_code=r.status_code if r else 500,
|
||||
detail=error_detail,
|
||||
)
|
||||
else:
|
||||
return {"version": False}
|
||||
|
||||
|
||||
class ModelNameForm(BaseModel):
|
||||
|
||||
@@ -84,3 +84,7 @@ class ERROR_MESSAGES(str, Enum):
|
||||
WEB_SEARCH_ERROR = (
|
||||
lambda err="": f"{err if err else 'Oops! Something went wrong while searching the web.'}"
|
||||
)
|
||||
|
||||
OLLAMA_API_DISABLED = (
|
||||
"The Ollama API is disabled. Please enable it to use this feature."
|
||||
)
|
||||
Reference in new issue
Block a user