| import os |
| import sys |
| import json |
| from typing import Dict, Any |
|
|
| |
| sys.path.append(os.getcwd()) |
|
|
| from backend.env import CustomerSupportEnv |
| from backend.models import Action, TicketStatus |
|
|
| def run_baseline(): |
| print("π [BASELINE] Starting Real-world Support Workflow Demo...") |
| env = CustomerSupportEnv() |
| obs = env.reset() |
| |
| total_reward = 0.0 |
| steps = 0 |
| |
| |
| while obs.state.get("status") != TicketStatus.SESSION_COMPLETE: |
| steps += 1 |
| gt = env.ground_truth |
| if not gt: |
| break |
| |
| ticket_text = obs.state.get("ticket_text", "") |
| print(f"\nπ« Step {steps}: Processing Ticket: \"{ticket_text[:50]}...\"") |
| |
| |
| action = Action( |
| action_type="classify_ticket", |
| payload={"classification": gt["expected_classification"]} |
| ) |
| obs, reward, done, info = env.step(action) |
| total_reward += reward.value |
| print(f" ββ Action: Classify -> {gt['expected_classification']} | Reward: {reward.value:+.2f}") |
| |
| |
| action = Action( |
| action_type="assign_priority", |
| payload={"priority": gt["expected_priority"]} |
| ) |
| obs, reward, done, info = env.step(action) |
| total_reward += reward.value |
| print(f" ββ Action: Priority -> {gt['expected_priority']} | Reward: {reward.value:+.2f}") |
| |
| |
| empathy = "I am so sorry for the inconvenience, I understand your concern." |
| action = Action( |
| action_type="generate_response", |
| payload={"response": empathy} |
| ) |
| obs, reward, done, info = env.step(action) |
| total_reward += reward.value |
| print(f" ββ Action: Respond -> [Empathetic Draft] | Reward: {reward.value:+.2f}") |
| |
| |
| action = Action(action_type="resolve", payload={}) |
| obs, reward, done, info = env.step(action) |
| total_reward += reward.value |
| print(f" ββ Action: Resolve -> Ticket Closed | Reward: {reward.value:+.2f}") |
|
|
| print("\n" + "="*50) |
| print(f"β¨ BASELINE COMPLETE") |
| print(f"π Total Reward Earned: {total_reward:.2f}") |
| print(f"π Final Status: {obs.state.get('status')}") |
| print("="*50) |
|
|
| if __name__ == "__main__": |
| try: |
| run_baseline() |
| except Exception as e: |
| print(f"β Baseline failed: {e}") |
| sys.exit(1) |
|
|