Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- inference.py +10 -8
inference.py
CHANGED
|
@@ -34,12 +34,9 @@ except ImportError:
|
|
| 34 |
# Configuration - EXACTLY per spec: defaults for API_BASE_URL and MODEL_NAME
|
| 35 |
# ---------------------------------------------------------------------------
|
| 36 |
|
| 37 |
-
API_BASE_URL = os.
|
| 38 |
-
MODEL_NAME = os.getenv("MODEL_NAME", "gpt-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
if HF_TOKEN is None:
|
| 42 |
-
raise ValueError("HF_TOKEN environment variable is required")
|
| 43 |
|
| 44 |
SERVER_URL = os.getenv("SERVER_URL", "http://localhost:7860")
|
| 45 |
SEED = 42
|
|
@@ -154,8 +151,13 @@ def run_task(task: str, client: OpenAI) -> dict:
|
|
| 154 |
success = done and last_error is None
|
| 155 |
rewards_str = ",".join(f"{r:.2f}" for r in rewards)
|
| 156 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
print(
|
| 158 |
-
f'[END] success={str(success).lower()} steps={step} rewards={rewards_str}',
|
| 159 |
flush=True,
|
| 160 |
)
|
| 161 |
|
|
@@ -171,7 +173,7 @@ def main():
|
|
| 171 |
# Initialize OpenAI client per spec
|
| 172 |
client = OpenAI(
|
| 173 |
base_url=API_BASE_URL,
|
| 174 |
-
api_key=
|
| 175 |
)
|
| 176 |
|
| 177 |
tasks = ["basic_flow", "emergency_priority", "dynamic_scenarios"]
|
|
|
|
| 34 |
# Configuration - EXACTLY per spec: defaults for API_BASE_URL and MODEL_NAME
|
| 35 |
# ---------------------------------------------------------------------------
|
| 36 |
|
| 37 |
+
API_BASE_URL = os.environ["API_BASE_URL"]
|
| 38 |
+
MODEL_NAME = os.getenv("MODEL_NAME", "gpt-4o-mini")
|
| 39 |
+
API_KEY = os.environ["API_KEY"]
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
SERVER_URL = os.getenv("SERVER_URL", "http://localhost:7860")
|
| 42 |
SEED = 42
|
|
|
|
| 151 |
success = done and last_error is None
|
| 152 |
rewards_str = ",".join(f"{r:.2f}" for r in rewards)
|
| 153 |
|
| 154 |
+
# Calculate normalized score [0, 1]
|
| 155 |
+
total_reward = sum(rewards)
|
| 156 |
+
max_possible = step * 10.0 # Approximate max per step
|
| 157 |
+
score = min(1.0, max(0.0, total_reward / max_possible)) if max_possible > 0 else 0.0
|
| 158 |
+
|
| 159 |
print(
|
| 160 |
+
f'[END] success={str(success).lower()} steps={step} score={score:.2f} rewards={rewards_str}',
|
| 161 |
flush=True,
|
| 162 |
)
|
| 163 |
|
|
|
|
| 173 |
# Initialize OpenAI client per spec
|
| 174 |
client = OpenAI(
|
| 175 |
base_url=API_BASE_URL,
|
| 176 |
+
api_key=API_KEY
|
| 177 |
)
|
| 178 |
|
| 179 |
tasks = ["basic_flow", "emergency_priority", "dynamic_scenarios"]
|