Support filter mapping
We want an endpoint that will make it possible to map a natural language query into a set of filters (the immediate use case of this is Torque's Explore
interface).
This endpoint should not be tightly coupled with Torque, but should instead accept information about both the query AND the domain that the endpoint will attempt to map onto. This will mean API calls over time will re-send a bunch of redundant information, but that's fine for now. We can always optimize in future to make the "filter set" an entity with its own REST endpoint if that's actually a useful optimization.
@justin drafted an example of what this API's signature might look like, for the purposes of brainstorming:
Query:
{
"query": "",
"filters": {
"competition": {
"label": "Competition",
"instructions": "[some long text describing this field to the LLM or giving field-specific instructions]",
"values": {
"100Change2020": {
"label": "100Change2020",
"instructions": "[some long text describing this value to the LLM or giving value-specific instructions]",
},
"BaWoP22": {
"label": "BaWoP22",
"instructions": "[some long text describing this value to the LLM or giving value-specific instructions]",
}
}
},
"rankPercentile": {
"label": "Rank Percentile",
"instructions": "[some long text describing this field to the LLM or giving field-specific instructions]",
"values": {
"95-100": {
"label": "95–100%",
"instructions": "[some long text describing this value to the LLM or giving value-specific instructions]",
},
"90-94": {
"label": "90–94%",
"instructions": "[some long text describing this value to the LLM or giving value-specific instructions]",
}
}
}
}
}
Result:
{
"query": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
"enabledFilters": {
"competition": ["100Change2020", "ECW2020"],
"rankPercentile": ["Unranked", "95-100"]
}
}
There was some discussion of this resulting in an entity with state (e.g. you could re-access the result of a filter mapping).