File size: 4,393 Bytes
53dbcc1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
"""Shared builders for Flatmate visit-scheduling scenarios."""

from __future__ import annotations

from copy import deepcopy
from typing import Any


def build_post(
    *,
    post_id: str,
    area: str,
    rent: int,
    diet: str,
    listing_type: str,
    commute_to_goregaon_mins: int,
    constraints: list[str],
    calendar_slots: list[str],
    description: str,
    pre_booked_slots: list[str] | None = None,
    amenities: dict[str, bool] | None = None,
    negotiable: bool = False,
) -> dict[str, Any]:
    return {
        "id": post_id,
        "area": area,
        "rent": rent,
        "diet": diet,
        "type": listing_type,
        "commute_to_goregaon_mins": commute_to_goregaon_mins,
        "constraints": list(constraints),
        "calendar_slots": list(calendar_slots),
        "pre_booked_slots": list(pre_booked_slots or []),
        "description": description,
        "amenities": dict(amenities or {}),
        "negotiable": negotiable,
    }


def build_buyer_profile(
    *,
    budget_max: int,
    dietary: str,
    areas: list[str],
    occupation: str,
    visit_availability: list[str],
    initial_disclosure_fields: list[str],
    hidden_additional_availability: list[str] | None = None,
    hidden_budget_ceiling: int | None = None,
) -> dict[str, Any]:
    return {
        "budget_max": budget_max,
        "dietary": dietary,
        "areas": list(areas),
        "occupation": occupation,
        "visit_availability": list(visit_availability),
        "initial_disclosure_fields": list(initial_disclosure_fields),
        "hidden_additional_availability": list(hidden_additional_availability or []),
        "hidden_budget_ceiling": hidden_budget_ceiling,
    }


def build_seller_profile(
    *,
    area: str,
    rent: int,
    dietary: str,
    listing_type: str,
    occupation_requirement: str,
    calendar_slots: list[str],
    description: str,
    commute_to_goregaon_mins: int,
    constraints: list[str],
) -> dict[str, Any]:
    return {
        "area": area,
        "rent": rent,
        "dietary": dietary,
        "listing_type": listing_type,
        "occupation_requirement": occupation_requirement,
        "calendar_slots": list(calendar_slots),
        "description": description,
        "commute_to_goregaon_mins": commute_to_goregaon_mins,
        "constraints": list(constraints),
    }


def build_ground_truth(
    *,
    optimal_posts: list[str],
    acceptable_posts: list[str],
    dealbreaker_posts: list[str],
    required_bookings: int,
    required_tool_calls: list[str],
    required_info: list[str],
    success_condition: str,
    min_viable_turns: int,
    schedule_feasible_posts: list[str] | None = None,
    max_schedule_feasible_visits: int | None = None,
) -> dict[str, Any]:
    payload = {
        "optimal_posts": list(optimal_posts),
        "acceptable_posts": list(acceptable_posts),
        "dealbreaker_posts": list(dealbreaker_posts),
        "required_bookings": required_bookings,
        "required_tool_calls": list(required_tool_calls),
        "required_info": list(required_info),
        "success_condition": success_condition,
        "min_viable_turns": min_viable_turns,
    }
    if schedule_feasible_posts is not None:
        payload["schedule_feasible_posts"] = list(schedule_feasible_posts)
    if max_schedule_feasible_visits is not None:
        payload["max_schedule_feasible_visits"] = max_schedule_feasible_visits
    return payload


def build_visit_scenario(
    *,
    task_id: str,
    label: str,
    difficulty: str,
    description: str,
    task_post_ids: list[str],
    buyer_profile: dict[str, Any],
    ground_truth: dict[str, Any],
    scenario_creation_config: dict[str, Any],
    initial_user_message: str,
    seller_profile: dict[str, Any] | None = None,
    seller_initial_message: str | None = None,
) -> dict[str, Any]:
    return {
        "task_id": task_id,
        "label": label,
        "difficulty": difficulty,
        "description": description,
        "task_post_ids": list(task_post_ids),
        "buyer_profile": deepcopy(buyer_profile),
        "seller_profile": deepcopy(seller_profile),
        "ground_truth": deepcopy(ground_truth),
        "scenario_creation_config": deepcopy(scenario_creation_config),
        "initial_user_message": initial_user_message,
        "seller_initial_message": seller_initial_message or "",
    }