Open simeonwetzel opened 3 months ago
Temporal and spatial filters can now be passed to the chatbot API-endpoint.
Next to the text input (query
) parameter it now allows an optional spatio_temporal_context
param like:
{
"query": "Can you show me building data for Dresden? I need hospitals",
"spatio_temporal_context": {"temporal": "2020-2021","extent": [13.5793237, 51.1777202, 14.9660626, 50.974937]}
}
Usage:
curl -X POST http://localhost:8000/data \
-H "Content-Type: application/json" \
-d '{
"query": "Can you show me building data for Dresden? I need hospitals",
"spatio_temporal_context": {
"temporal": "2020-2021",
"extent": [13.5793237, 51.1777202, 14.9660626, 50.974937]
}
}'
Endpoint implemenation details: https://github.com/52North/innovation-prize/blob/c1a3b0aba98cfe3634c0ad0a0e030c0d2e6bb9c9/search-app/server/app/server.py#L150-L167
The spatio_temporal_context
parameter is optional. If users do not provide it, an LLM+tools is used to derive the spatial context automatically.
Example:
"query": "Can you show me building data for Dresden?"
Extraced spatial context:
{'name': 'Dresden', 'country': 'Deutschland', 'type': 'city', 'extent': [13.5793237, 51.1777202, 13.9660626, 50.974937]}
How it works:
prompt="""You are an expert in geography and spatial data.
Your task is to extract from a query spatial entities such as city, country or region names.
Also determine the spatial scale ("Local", "City", "Regional", "National", "Continental", "Global") from the given query.
"""
We use another LLM to get the most reasonable candidate of the komoot results. Used prompt:
prompt="""You are an expert in geography and spatial data.
Your task is to pick from the results list the best matching candidate according to the query.
If the original query includes a country information, consider this in your selection.
If also consider the type. E.g. if user asks for a 'river' also pick the corresponding result
Also consider the scale: {scale}
Query: {original_query}
Results: {results}
Output:"""
In addition to text inputs, the API-endpoint for conversational chatbot should also be able to consume temporal or spatial constraints via the API requests.