I have an app that stores lots of data that is of interest to the user. Analogies would be the Photos apps or the Health app.
I'm trying to use the Foundation Models framework to allow users to surface information they find interesting using natural language, for example, "Tell me about the widgets from yesterday" or "Tell me about the widgets for the last 3 days". Specifically, I'm trying to get a date range passed down to the Tool so that I can pull the relevant widgets from the database in the call function.
What is the right way to set up the Arguments to get at a date range?
Our recommendation is to write a date components like struct that is Generable and contains only the date components you care about. make the model generate that struct, and then manually convert it into a date object.
You might have something like this:
@Generable struct Arguments {
var startDate: CalendarDateComponents?
var endDate: CalendarDateComponents?
}
@Generable struct CalendarDateComponents {
var year: Int
var month: Int
var day: Int
}
When prompting, make sure to tell the model the current date.