Spaces:
Sleeping
Sleeping
Update inference.py
Browse files- inference.py +7 -9
inference.py
CHANGED
|
@@ -129,31 +129,31 @@ def run_inference():
|
|
| 129 |
|
| 130 |
step_results = []
|
| 131 |
|
|
|
|
|
|
|
| 132 |
# Run until episode is done
|
| 133 |
while not state["done"]:
|
| 134 |
current_step = state["step"] + 1
|
| 135 |
email = state["email"]
|
| 136 |
|
| 137 |
-
print(f"Step {current_step}/{state['max_steps']}")
|
| 138 |
print(f"Subject: {email['subject']}")
|
| 139 |
print(f"From: {email['sender']}")
|
| 140 |
|
| 141 |
# Ask AI to classify
|
| 142 |
action = ask_llm_to_classify(email)
|
| 143 |
-
print(f"AI Decision: {action}")
|
| 144 |
|
| 145 |
# Take step in environment
|
| 146 |
next_state, reward, done, info = env.step(action)
|
| 147 |
|
| 148 |
-
|
| 149 |
-
print("
|
| 150 |
|
| 151 |
step_results.append({
|
| 152 |
"step": current_step,
|
| 153 |
"subject": email["subject"],
|
| 154 |
"action": action,
|
| 155 |
"reward": reward,
|
| 156 |
-
"result":
|
| 157 |
})
|
| 158 |
|
| 159 |
state = next_state
|
|
@@ -175,7 +175,6 @@ def run_inference():
|
|
| 175 |
print(f"Total Reward: {total_reward}")
|
| 176 |
print("=" * 50)
|
| 177 |
|
| 178 |
-
# Save results to file
|
| 179 |
results = {
|
| 180 |
"model": MODEL_NAME,
|
| 181 |
"total_steps": total_steps,
|
|
@@ -185,10 +184,9 @@ def run_inference():
|
|
| 185 |
"step_details": step_results
|
| 186 |
}
|
| 187 |
|
| 188 |
-
|
| 189 |
-
|
| 190 |
|
| 191 |
-
print("\nResults saved to inference_results.json")
|
| 192 |
return results
|
| 193 |
|
| 194 |
|
|
|
|
| 129 |
|
| 130 |
step_results = []
|
| 131 |
|
| 132 |
+
print(f"[START] task=email_sorting", flush=True)
|
| 133 |
+
|
| 134 |
# Run until episode is done
|
| 135 |
while not state["done"]:
|
| 136 |
current_step = state["step"] + 1
|
| 137 |
email = state["email"]
|
| 138 |
|
|
|
|
| 139 |
print(f"Subject: {email['subject']}")
|
| 140 |
print(f"From: {email['sender']}")
|
| 141 |
|
| 142 |
# Ask AI to classify
|
| 143 |
action = ask_llm_to_classify(email)
|
|
|
|
| 144 |
|
| 145 |
# Take step in environment
|
| 146 |
next_state, reward, done, info = env.step(action)
|
| 147 |
|
| 148 |
+
result = info.get("result", "N/A")
|
| 149 |
+
print(f"[STEP] step={current_step} action={action} reward={reward} result={result}", flush=True)
|
| 150 |
|
| 151 |
step_results.append({
|
| 152 |
"step": current_step,
|
| 153 |
"subject": email["subject"],
|
| 154 |
"action": action,
|
| 155 |
"reward": reward,
|
| 156 |
+
"result": result
|
| 157 |
})
|
| 158 |
|
| 159 |
state = next_state
|
|
|
|
| 175 |
print(f"Total Reward: {total_reward}")
|
| 176 |
print("=" * 50)
|
| 177 |
|
|
|
|
| 178 |
results = {
|
| 179 |
"model": MODEL_NAME,
|
| 180 |
"total_steps": total_steps,
|
|
|
|
| 184 |
"step_details": step_results
|
| 185 |
}
|
| 186 |
|
| 187 |
+
score = round(correct_count / total_steps, 4) if total_steps > 0 else 0.0
|
| 188 |
+
print(f"[END] task=email_sorting score={score} steps={total_steps}", flush=True)
|
| 189 |
|
|
|
|
| 190 |
return results
|
| 191 |
|
| 192 |
|