44Enter vague, unstructured info like:
55
66M-F 8-3pm at home or Tue/Wed 9-1030am at daycare
7+
8+ Run like this --
9+
10+ ```bash
11+ uv run examples/basic/schedule-extract.py -m
712"""
813
914import langroid as lr
1015import langroid .language_models as lm
11- from enum import Enum
1216from langroid .agent .tools .orchestration import FinalResultTool
13- from typing import List , Dict , Tuple
17+ from typing import List , Dict , Literal , Tuple
1418from langroid .pydantic_v1 import BaseModel , Field
1519from rich .prompt import Prompt
1620from fire import Fire
1721
1822
1923class Slot (BaseModel ):
20- start_time : float = Field (..., description = "start time of the slot, e.g. 11:30AM" )
21- duration : float = Field (..., description = "duration of the slot in MINUTES " )
24+ start_time : str = Field (..., description = "start time of the slot, e.g. 11:30AM" )
25+ end_time : str = Field (..., description = "end time of the slot, e.g. 12:30PM " )
2226 location : str = Field (..., description = "location of the slot or UNKNOWN" )
2327
2428
@@ -30,28 +34,19 @@ class DaySchedule(BaseModel):
3034 slots : List [Slot ] = Field (..., description = "List of time slots for the day" )
3135
3236
33- class Weekday (int , Enum ):
34- """
35- A class to represent a weekday.
36- """
37-
38- MON = 0
39- TUE = 1
40- WED = 2
41- THU = 3
42- FRI = 4
37+ Weekday = Literal ["Mon" , "Tue" , "Wed" , "Thu" , "Fri" ]
4338
4439
4540class Availability (BaseModel ):
4641 """
4742 A class to represent schedule information.
4843 """
4944
50- week_availability : Dict [int , DaySchedule ] = Field (
45+ week_availability : Dict [Weekday , DaySchedule ] = Field (
5146 ...,
5247 description = """
5348 Dictionary mapping weekday to DaySchedule,
54- where 0 = Monday, 1 = Tuesday, ... 4 = Friday
49+ where weekday is one of "Mon", "Tue", "Wed", "Thu", "Fri"
5550 """ ,
5651 )
5752
@@ -77,17 +72,27 @@ def examples(cls) -> List["lr.ToolMessage" | Tuple[str, "lr.ToolMessage"]]:
7772 cls (
7873 availabilities = Availability (
7974 week_availability = {
80- Weekday . MON : DaySchedule (
75+ "Mon" : DaySchedule (
8176 slots = [
82- Slot (start_time = 10 , duration = 360 , location = "home" ),
8377 Slot (
84- start_time = 15 , duration = 60 , location = "daycare"
78+ start_time = "10:00" ,
79+ end_time = "16:00" ,
80+ location = "home" ,
81+ ),
82+ Slot (
83+ start_time = "15:00" ,
84+ end_time = "16:00" ,
85+ location = "daycare" ,
8586 ),
8687 ]
8788 ),
88- Weekday . WED : DaySchedule (
89+ "Wed" : DaySchedule (
8990 slots = [
90- Slot (start_time = 10 , duration = 360 , location = "home" )
91+ Slot (
92+ start_time = "10:00" ,
93+ end_time = "16:00" ,
94+ location = "home" ,
95+ )
9196 ]
9297 ),
9398 }
@@ -110,7 +115,7 @@ def handle(self) -> str:
110115
111116def make_schedule_task (model : str = "" ):
112117 llm_config = lm .OpenAIGPTConfig (
113- chat_model = model or lm .GeminiModel . GEMINI_2_FLASH_LITE ,
118+ chat_model = model or lm .OpenAIChatModel . GPT4o_MINI ,
114119 )
115120 agent = lr .ChatAgent (
116121 lr .ChatAgentConfig (
0 commit comments