mirror of
https://github.com/arkorty/B.Tech-Project-III.git
synced 2026-04-19 12:41:48 +00:00
60 lines
2.5 KiB
Python
60 lines
2.5 KiB
Python
# test_negotiation.py
|
|
import asyncio
|
|
import json
|
|
import os
|
|
import sys
|
|
backend_path = os.path.join(os.path.dirname(__file__), '..', 'backend')
|
|
sys.path.insert(0, backend_path)
|
|
async def on_round(data):
|
|
print(f"\n🔄 Round {data['round_number']}: {data['action']}")
|
|
print(f" Satisfaction A: {data.get('satisfaction_a', '?')}% B: {data.get('satisfaction_b', '?')}%")
|
|
print(f" Reasoning: {data['reasoning']}")
|
|
|
|
async def on_resolve(data):
|
|
print(f"\n{'='*50}")
|
|
print(f"🏁 RESULT: {data['status']} in {data['rounds_taken']} rounds")
|
|
print(f" Summary: {data['summary']}")
|
|
print(f" Timeline: {json.dumps(data.get('satisfaction_timeline', []))}")
|
|
|
|
async def test():
|
|
from agents.negotiation import run_negotiation
|
|
import database as db
|
|
|
|
await db.init_db()
|
|
|
|
# Test with DIFFERENT personalities: aggressive vs empathetic
|
|
prefs_a = {
|
|
"feature_type": "expenses",
|
|
"goal": "Split Goa trip expenses",
|
|
"constraints": [{"type": "budget", "value": None, "description": "Fair split", "hard": True}],
|
|
"preferences": [
|
|
{"type": "split", "value": "60-40 fuel", "priority": "high", "description": "I drove the whole way"},
|
|
{"type": "payment", "value": "UPI", "priority": "medium", "description": "UPI preferred"}
|
|
],
|
|
"raw_details": {"hotel": 12000, "fuel": 3000, "dinner": 2000, "upi_id": "rahul@paytm"}
|
|
}
|
|
prefs_b = {
|
|
"feature_type": "expenses",
|
|
"goal": "Split Goa trip expenses fairly",
|
|
"constraints": [{"type": "fairness", "value": "equal contribution acknowledged", "hard": False}],
|
|
"preferences": [
|
|
{"type": "split", "value": "50-50 fuel", "priority": "high", "description": "I navigated and planned"},
|
|
{"type": "payment", "value": "UPI", "priority": "medium", "description": "UPI fine"}
|
|
],
|
|
"raw_details": {"hotel": 12000, "fuel": 3000, "dinner": 2000}
|
|
}
|
|
|
|
neg_id = await db.create_negotiation("expenses", 111)
|
|
await db.add_participant(neg_id, 111, prefs_a, personality_used="aggressive")
|
|
await db.add_participant(neg_id, 222, prefs_b, personality_used="empathetic")
|
|
|
|
print("🧪 Testing: AGGRESSIVE (A) vs EMPATHETIC (B) on expense splitting\n")
|
|
result = await run_negotiation(
|
|
negotiation_id=neg_id, preferences_a=prefs_a, preferences_b=prefs_b,
|
|
user_a_id=111, user_b_id=222, feature_type="expenses",
|
|
personality_a="aggressive", personality_b="empathetic",
|
|
on_round_update=on_round, on_resolution=on_resolve
|
|
)
|
|
|
|
asyncio.run(test())
|