from tools.nlu_tool import extract_intent_and_slots from tools.scheduler import find_common_slots, get_operator_availability import datetime import pytz from app import propose_slots print('NLU test 1:') r1 = extract_intent_and_slots('I can pay ¥30000 by next Friday') print(r1) print('parsed date_by_when:', r1.get('slots', {}).get('date_by_when')) print('\nNLU test 2:') print(extract_intent_and_slots('I need to talk to an operator')) print('\nScheduler sample operator slots (first 3):') ops = get_operator_availability() for s in ops[:3]: print(s.isoformat()) # Example customer window for find_common_slots (timezone-aware Asia/Tokyo) TZ = pytz.timezone('Asia/Tokyo') now = datetime.datetime.now(TZ) start = TZ.localize(datetime.datetime(now.year, now.month, now.day, 9)) + datetime.timedelta(days=2) end = TZ.localize(datetime.datetime(now.year, now.month, now.day, 12)) + datetime.timedelta(days=2) slots = find_common_slots([{'start': start, 'end': end}]) print('\nCommon slots:') for s in slots: print(s) print('\nPropose slots using preferred window ("tomorrow 09:00" to "tomorrow 12:00")') prefs = [{'start': 'tomorrow 09:00', 'end': 'tomorrow 12:00'}] print(propose_slots(prefs))