- MLX(맥미니 27B) 우선 → Ollama(조립컴 9B) fallback 구조 - pydantic-settings 기반 config 전환 - health check에 MLX 상태 추가 - 텍스트 모델 qwen3:8b → qwen3.5:9b-q8_0 변경 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
23 lines
560 B
Python
23 lines
560 B
Python
import json
|
|
import os
|
|
|
|
_BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
|
|
def load_prompt(path: str) -> str:
|
|
full_path = os.path.join(_BASE_DIR, path)
|
|
with open(full_path, "r", encoding="utf-8") as f:
|
|
return f.read()
|
|
|
|
|
|
def parse_json_response(raw: str) -> dict:
|
|
"""LLM 응답에서 JSON을 추출합니다."""
|
|
start = raw.find("{")
|
|
end = raw.rfind("}") + 1
|
|
if start == -1 or end == 0:
|
|
return {}
|
|
try:
|
|
return json.loads(raw[start:end])
|
|
except json.JSONDecodeError:
|
|
return {}
|