mirror of
https://github.com/open-webui/open-webui
synced 2024-12-29 15:25:29 +00:00
add ollama ps endpoint
This commit is contained in:
parent
c4ea31357f
commit
9c554db37c
@ -431,6 +431,25 @@ async def get_ollama_versions(url_idx: Optional[int] = None):
|
|||||||
else:
|
else:
|
||||||
return {"version": False}
|
return {"version": False}
|
||||||
|
|
||||||
|
@app.get("/api/ps")
|
||||||
|
async def get_ollama_loaded_models(user=Depends(get_verified_user)):
|
||||||
|
"""
|
||||||
|
List models that are currently loaded into Ollama memory, and which node they are loaded on.
|
||||||
|
"""
|
||||||
|
if app.state.config.ENABLE_OLLAMA_API:
|
||||||
|
tasks = [
|
||||||
|
aiohttp_get(
|
||||||
|
f"{url}/api/ps",
|
||||||
|
app.state.config.OLLAMA_API_CONFIGS.get(url, {}).get("key", None),
|
||||||
|
)
|
||||||
|
for url in app.state.config.OLLAMA_BASE_URLS
|
||||||
|
]
|
||||||
|
responses = await asyncio.gather(*tasks)
|
||||||
|
|
||||||
|
return dict(zip(app.state.config.OLLAMA_BASE_URLS, responses))
|
||||||
|
else:
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
class ModelNameForm(BaseModel):
|
class ModelNameForm(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
|
Loading…
Reference in New Issue
Block a user