-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocal_detector.py
More file actions
24 lines (20 loc) · 929 Bytes
/
local_detector.py
File metadata and controls
24 lines (20 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import asyncio
import httpx
import os
async def detect_local_providers():
"""Detects running local providers and sets defaults without requiring .env files."""
ollama_running = False
try:
async with httpx.AsyncClient() as client:
response = await client.get("http://localhost:11434/api/tags", timeout=5.0)
if response.status_code == 200:
ollama_running = True
print("[HANERMA] Ollama detected at localhost:11434. Setting as default provider.")
os.environ["HANERMA_DEFAULT_PROVIDER"] = "ollama"
except httpx.RequestError:
print("[HANERMA] Ollama not accessible at localhost:11434.")
if not ollama_running:
print("[HANERMA] No local providers detected. Using cloud defaults.")
os.environ["HANERMA_DEFAULT_PROVIDER"] = "cloud"
if __name__ == "__main__":
asyncio.run(detect_local_providers())