basic parsing working

This commit is contained in:
2025-12-11 12:56:23 +01:00
parent b023d44934
commit e576f98cce
10 changed files with 411 additions and 183 deletions

42
utils/ollama_utils.py Normal file
View File

@@ -0,0 +1,42 @@
import requests
from ollama import Client
def connect_qumo_ollama(vm_name: str ='ollama-lite', port='11434', print_models=True) -> Client:
"""Establish connection to Qumo Ollama instance
vm_name: str ('ollama-lite' or 'hiperf-gpu')
Name of the VM running the Ollama instance
Returns:
tuple(Client): Ollama client connected to the specified VM
"""
QUMO_OLLAMA_URL = f'http://{vm_name}.tail44fa00.ts.net:{port}'
if vm_name in ['localhost', '0.0.0.0']:
QUMO_OLLAMA_URL = f"http://{vm_name}:{port}"
try:
requests.get(QUMO_OLLAMA_URL, timeout=5)
client = Client(
host=QUMO_OLLAMA_URL
)
print(f"Connection succesful. WebUI available at: {QUMO_OLLAMA_URL.replace(port, '3000')}")
models = [m.model for m in client.list().models]
if print_models:
print("Available models:")
for m in models:
print(f" - '{m}' ")
return client, models
except requests.ConnectionError:
pass
print(f"Failed to reach {QUMO_OLLAMA_URL}. Check that the VM is running and Tailscale is up")
return None, None