| import json |
| import sys |
| import os |
|
|
| |
| sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
|
|
| from backend.env import CustomerSupportEnv |
| from backend.models import Action |
|
|
| def test_kb_and_sentiment(): |
| env = CustomerSupportEnv() |
| print("--- Testing Reset ---") |
| obs = env.reset() |
| ticket_text = obs.state["ticket_text"] |
| print(f"Initial Ticket: {ticket_text}") |
| print(f"Initial Sentiment: {obs.state['sentiment']}") |
|
|
| print("\n--- Testing KB Search ---") |
| action = Action(action_type="search_kb", payload={"query": "refund policy"}) |
| obs, reward, done, info = env.step(action) |
| print(f"Message: {info['message']}") |
| print(f"KB Context in Obs: {obs.state.get('kb_context')}") |
|
|
| print("\n--- Testing Sentiment Decay ---") |
| |
| for i in range(2): |
| action = Action(action_type="generate_response", payload={"response": "Wait..."}) |
| obs, reward, done, info = env.step(action) |
| print(f"Step {i+2} Sentiment: {obs.state['sentiment']}") |
| |
| |
| action = Action(action_type="generate_response", payload={"response": "Almost there..."}) |
| obs, reward, done, info = env.step(action) |
| print(f"Step 4 Sentiment: {obs.state['sentiment']}") |
| print(f"Message: {info['message']}") |
|
|
| print("\n--- Testing Clarification ---") |
| |
| action = Action(action_type="ask_clarification", payload={"question": "What is wrong?"}) |
| obs, reward, done, info = env.step(action) |
| print(f"Is Clarified in Obs: {obs.state.get('is_clarified')}") |
| print(f"Message: {info['message']}") |
|
|
| if __name__ == "__main__": |
| test_kb_and_sentiment() |
|
|