Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- inference.py +1 -16
inference.py
CHANGED
|
@@ -255,22 +255,7 @@ def main() -> None:
|
|
| 255 |
api_key = os.environ["API_KEY"]
|
| 256 |
print(f"[INIT] Creating OpenAI client with base_url={api_base}", flush=True)
|
| 257 |
client = OpenAI(base_url=api_base, api_key=api_key)
|
| 258 |
-
|
| 259 |
-
# Test API call to verify proxy connection
|
| 260 |
-
print(f"[INIT] Testing API connection...", flush=True)
|
| 261 |
-
try:
|
| 262 |
-
test_resp = client.chat.completions.create(
|
| 263 |
-
model=MODEL_NAME,
|
| 264 |
-
messages=[{"role": "user", "content": "Say 'API OK'"}],
|
| 265 |
-
max_tokens=10,
|
| 266 |
-
temperature=0,
|
| 267 |
-
)
|
| 268 |
-
print(f"[INIT] API test success: {test_resp.choices[0].message.content}", flush=True)
|
| 269 |
-
except Exception as e:
|
| 270 |
-
print(f"[INIT] API test failed: {e}", flush=True)
|
| 271 |
-
raise
|
| 272 |
-
|
| 273 |
-
print(f"[INIT] Client ready, will call LLM for every decision", flush=True)
|
| 274 |
|
| 275 |
# Fast reconnect logic with smart port discovery
|
| 276 |
import time
|
|
|
|
| 255 |
api_key = os.environ["API_KEY"]
|
| 256 |
print(f"[INIT] Creating OpenAI client with base_url={api_base}", flush=True)
|
| 257 |
client = OpenAI(base_url=api_base, api_key=api_key)
|
| 258 |
+
print(f"[INIT] Client ready, calling LLM for every decision", flush=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
|
| 260 |
# Fast reconnect logic with smart port discovery
|
| 261 |
import time
|