us how to use Foundation Models Prompt a Model Manage sessions Generate Swift Structs Stream Responses Call tools Manage Context Use multimodal input Build agents
Plan your day. Stay on track. Calendar All your events. In one place. Places Save and organize important locations. Contacts Keep the people who matter close. Notes Capture ideas and important details.
FetchContactsTool(), FetchLocationsTool() ], instructions: """ You are LifeHub's personal productivity assistant. Help the user decide what to do next. Use the available tools to fetch tasks, calendar events, contacts, and saved locations as needed. Consider task priorities, deadlines, estimated durations, upcoming events, and relevant people and places. Prefer overdue and high-priority tasks. Never recommend completed or blocked tasks. Only suggest tasks that fit before the next event. Consider travel time when a task requires a specific location. ) Recommend one task and briefly explain why it fits. """ let response = try await session.respond( to: """ What should I do next? """ ) print(response.content)
FetchContactsTool(), FetchLocationsTool() ], instructions: """ You are LifeHub's personal productivity assistant. Help the user decide what to do next. Use the available tools to fetch tasks, calendar events, contacts, and saved locations as needed. Consider task priorities, deadlines, estimated durations, upcoming events, and relevant people and places. Prefer overdue and high-priority tasks. Never recommend completed or blocked tasks. Only suggest tasks that fit before the next event. Consider travel time when a task requires a specific location. ) Recommend one task and briefly explain why it fits. """ let response = try await session.respond( to: """ What should I do next? """ ) print(response.content)
FetchContactsTool(), FetchLocationsTool() ], instructions: """ You are LifeHub's personal productivity assistant. Help the user decide what to do next. Use the available tools to fetch tasks, calendar events, contacts, and saved locations as needed. Consider task priorities, deadlines, estimated durations, upcoming events, and relevant people and places. Prefer overdue and high-priority tasks. Never recommend completed or blocked tasks. Only suggest tasks that fit before the next event. Consider travel time when a task requires a specific location. ) Recommend one task and briefly explain why it fits. """ let response = try await session.respond( to: """ What should I do next? """ ) print(response.content)
FetchContactsTool(), FetchLocationsTool() ], instructions: """ You are LifeHub's personal productivity assistant. Help the user decide what to do next. Use the available tools to fetch tasks, calendar events, contacts, and saved locations as needed. Consider task priorities, deadlines, estimated durations, upcoming events, and relevant people and places. Prefer overdue and high-priority tasks. Never recommend completed or blocked tasks. Only suggest tasks that fit before the next event. Consider travel time when a task requires a specific location. ) Recommend one task and briefly explain why it fits. """ let response = try await session.respond( to: """ What should I do next? """ ) print(response.content)
FetchContactsTool(), FetchLocationsTool() ], instructions: """ You are LifeHub's personal productivity assistant. Help the user decide what to do next. Use the available tools to fetch tasks, calendar events, contacts, and saved locations as needed. Consider task priorities, deadlines, estimated durations, upcoming events, and relevant people and places. Prefer overdue and high-priority tasks. Never recommend completed or blocked tasks. Only suggest tasks that fit before the next event. Consider travel time when a task requires a specific location. ) Recommend one task and briefly explain why it fits. """ let response = try await session.respond( to: """ What should I do next? """ ) print(response.content)
expense report 4 Duration: 15 min 5 Due: Today 6 7 - Call insurance company 8 Duration: 20 min 9 Due: This week 10 11 - Buy groceries 12 Duration: 30 min 13 Note: Supermarket is on route home 14 15 - Finish presentation 16 Duration: 90 min 17 18 19 Due: In 3 days
need later WHAT THE FEATURE NEEDS WHAT THE REASONING MAY NEED title estimatedDuration dueDate requiredLocation isCompleted isInterruptible canBeRescheduled energyLevel priority
expense report 4 Duration: 15 min 5 Due: Today 6 7 - Call insurance company 8 Duration: 20 min 9 Due: This week 10 11 - Buy groceries 12 Duration: 30 min 13 Note: Supermarket is on route home 14 15 - Finish presentation 16 Duration: 90 min 17 18 19 Due: In 3 days
come from? What is the time now? What is my location? Am I driving? # CURRENT STATE currentScreen: Task Details previousScreen: Home currentTime: 16:40 currentLocation: Work isDriving: false
come from? What is the time now? # CURRENT STATE currentScreen: previousScreen: currentTime: What is my location? Am I driving? currentLocation: isDriving: Task Details Home 16:40 Work false
What screen am I on? Where did I come from? What is the time now? What is my location? Am I driving? Work # CURRENT STATE currentScreen: previousScreen: currentTime: currentLocation: isDriving: Task Details Home Afternoon Work false
context Tool-driven setup # Instructions Consider priorities, deadlines, time, and location. Never recommend completed or blocked tasks. # Relevant facts Expense report, 15 min, due today Insurance call, 20 min, due this week Groceries, 30 min, on route home Presentation, 90 min, due in 3 days # Available tools FetchTasksTool FetchEventsTool FetchContactsTool FetchLocationsTool # Current state 16:40, at work Task Details open, not driving Reason about the situation ff Discover the situation
min Available time O ce Current location Tasks Situation detected PRODUCTIVITY KNOWLEDGE SHORT WORK WINDOW Working in short time blocks Scheduling deep work Planning around energy Review pull requests Prepare presentation, ffi Review architecture Task Switching & Setup cost
min Available time O ce Current location Tasks Review pull requests Prepare presentation, fi fi ffi Review architecture Retrieved Knowledge When time is limited, prefer small, well-de ned tasks with low setup costs and clear stopping points. Avoid starting deep, cognitively demanding work that requires signi cant ramp-up time.
try await contextBuilder.build() let session = LanguageModelSession( tools: [RecentBehaviorTool()], instructions: """ Recommend the best next task from the supplied context. Use a tool only when more information is required. """ ) let response = try await session.respond( to: "\(context)\n\nWhat should I do next?", generating: TaskSuggestion.self ) let suggestion = try taskPolicy.validate(response.content)
try await contextBuilder.build() let session = LanguageModelSession( tools: [RecentBehaviorTool()], instructions: """ Recommend the best next task from the supplied context. Use a tool only when more information is required. """ ) let response = try await session.respond( to: "\(context)\n\nWhat should I do next?", generating: TaskSuggestion.self ) let suggestion = try taskPolicy.validate(response.content)
[ TaskSearchTool(taskStore) ], It can search tasks. These are its arguments... instructions: ... ) There is a tool called TaskSearchTool. This is what it returns...
parallel. Dependent calls need another round. Weather Tool “Is it hotter in Orlando or Miami?” “What should we do next?” Reason Reason Weather Tool Reasoning Fetch Tasks Reasoning Fetch Events Reasoning
hard. Let it focus on reasoning. - Model your data for reasoning. - Use semantic meaning and not raw data. - If reasoning is not required, don’t use AI. - Don’t corporate with silly questions.