YUGOROU commited on
Commit ·
b9640bf
1
Parent(s): d2fa827
Integrate AMD MI300X lumi-grpo backend via gateway at 134.199.205.145:8080
Browse files- backend_api.py +9 -2
backend_api.py
CHANGED
|
@@ -26,8 +26,9 @@ from pipeline.profiles import get_profile
|
|
| 26 |
from pipeline.scam_filter import check_and_deflect
|
| 27 |
from pipeline.tts import synthesize
|
| 28 |
|
| 29 |
-
VLLM_BASE_URL
|
| 30 |
-
MODEL_NAME
|
|
|
|
| 31 |
PATIENT_ID = os.getenv("PATIENT_ID", "demo_user_001")
|
| 32 |
PATIENT_NAME = os.getenv("PATIENT_NAME", "Margaret")
|
| 33 |
|
|
@@ -35,6 +36,12 @@ llm = OpenAI(base_url=VLLM_BASE_URL, api_key="not-required")
|
|
| 35 |
|
| 36 |
|
| 37 |
def _call_llm(messages: list[dict]) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
resp = llm.chat.completions.create(
|
| 39 |
model=MODEL_NAME,
|
| 40 |
messages=messages,
|
|
|
|
| 26 |
from pipeline.scam_filter import check_and_deflect
|
| 27 |
from pipeline.tts import synthesize
|
| 28 |
|
| 29 |
+
VLLM_BASE_URL = os.getenv("VLLM_BASE_URL", "http://127.0.0.1:8000/v1")
|
| 30 |
+
MODEL_NAME = os.getenv("MODEL_NAME", "YUGOROU/lumi-grpo")
|
| 31 |
+
LUMI_GATEWAY_URL = os.getenv("LUMI_GATEWAY_URL", "http://134.199.205.145:8080")
|
| 32 |
PATIENT_ID = os.getenv("PATIENT_ID", "demo_user_001")
|
| 33 |
PATIENT_NAME = os.getenv("PATIENT_NAME", "Margaret")
|
| 34 |
|
|
|
|
| 36 |
|
| 37 |
|
| 38 |
def _call_llm(messages: list[dict]) -> str:
|
| 39 |
+
if LUMI_GATEWAY_URL:
|
| 40 |
+
import httpx as _httpx
|
| 41 |
+
r = _httpx.post(f"{LUMI_GATEWAY_URL}/chat",
|
| 42 |
+
json={"messages": messages}, timeout=60.0)
|
| 43 |
+
r.raise_for_status()
|
| 44 |
+
return r.json()["response"]
|
| 45 |
resp = llm.chat.completions.create(
|
| 46 |
model=MODEL_NAME,
|
| 47 |
messages=messages,
|