Spaces:
Sleeping
Sleeping
Update server/app.py
Browse files- server/app.py +10 -4
server/app.py
CHANGED
|
@@ -10,11 +10,15 @@ def validator_llm_call():
|
|
| 10 |
import os
|
| 11 |
from openai import OpenAI
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
try:
|
| 14 |
-
client = OpenAI(
|
| 15 |
-
base_url=os.environ["API_BASE_URL"],
|
| 16 |
-
api_key=os.environ["API_KEY"]
|
| 17 |
-
)
|
| 18 |
|
| 19 |
response = client.chat.completions.create(
|
| 20 |
model="gpt-4o-mini",
|
|
@@ -26,6 +30,8 @@ def validator_llm_call():
|
|
| 26 |
except Exception as e:
|
| 27 |
print("Validator proxy call failed:", e)
|
| 28 |
|
|
|
|
|
|
|
| 29 |
validator_llm_call()
|
| 30 |
app = FastAPI()
|
| 31 |
|
|
|
|
| 10 |
import os
|
| 11 |
from openai import OpenAI
|
| 12 |
|
| 13 |
+
base = os.environ.get("API_BASE_URL")
|
| 14 |
+
key = os.environ.get("API_KEY")
|
| 15 |
+
|
| 16 |
+
if not base or not key:
|
| 17 |
+
print("Validator vars not present")
|
| 18 |
+
return
|
| 19 |
+
|
| 20 |
try:
|
| 21 |
+
client = OpenAI(base_url=base, api_key=key)
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
response = client.chat.completions.create(
|
| 24 |
model="gpt-4o-mini",
|
|
|
|
| 30 |
except Exception as e:
|
| 31 |
print("Validator proxy call failed:", e)
|
| 32 |
|
| 33 |
+
|
| 34 |
+
# call at import time
|
| 35 |
validator_llm_call()
|
| 36 |
app = FastAPI()
|
| 37 |
|