feat: Ollama-Adapter gegen echtes Ollama geprüft, Vulkan und Runner-Prozesse behandelt (M2.6a)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -16,6 +16,7 @@ ohne SSE). Die Antwort nennt das Modell, das tatsächlich in der Anfrage stand.
|
||||
import json
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
@ -31,7 +32,7 @@ known = {m.strip() for m in os.environ.get("FAKE_OLLAMA_MODELS", "qwen3:0.6b,lla
|
||||
load_seconds = float(os.environ.get("FAKE_OLLAMA_LOAD_SECONDS", "0.3"))
|
||||
|
||||
print("fake-ollama: pid", os.getpid(), flush=True)
|
||||
for name in ("OLLAMA_HOST", "OLLAMA_MODELS", "OLLAMA_KEEP_ALIVE", "OLLAMA_NOPRUNE", "CUDA_VISIBLE_DEVICES"):
|
||||
for name in ("OLLAMA_HOST", "OLLAMA_MODELS", "OLLAMA_KEEP_ALIVE", "OLLAMA_NOPRUNE", "CUDA_VISIBLE_DEVICES", "OLLAMA_VULKAN", "OLLAMA_NO_CLOUD", "OLLAMA_DEBUG_LOG_REQUESTS"):
|
||||
print(f"fake-ollama: {name}={os.environ.get(name, '<unset>')}", flush=True)
|
||||
|
||||
if mode == "crash":
|
||||
@ -74,6 +75,11 @@ class Handler(BaseHTTPRequestHandler):
|
||||
def _load(self, model):
|
||||
time.sleep(load_seconds)
|
||||
with lock:
|
||||
if normalize(model) not in loaded:
|
||||
# Wie das echte Ollama: Ein Modell läuft in einem eigenen Prozess
|
||||
# (Runner), der den Server überleben kann, wenn dieser hart endet.
|
||||
runner = subprocess.Popen(["sleep", "15"])
|
||||
print(f"fake-ollama: runner {runner.pid}", flush=True)
|
||||
loaded[normalize(model)] = time.time()
|
||||
|
||||
def do_GET(self):
|
||||
|
||||
Reference in New Issue
Block a user