Introduction¶
The DeepSeek Harness (DSH) plugin xby-toronto-open-data-server is a tool for directly accessing Toronto Open Data through the CKAN API, maintained by xby-skill. The plugin is designed specifically for LLM agents, aiming to address issues in agent development such as API complexity, difficulty in dataset discovery, and tedious format handling when retrieving structured open data. By encapsulating the interfaces for Toronto open datasets, it provides a complete workflow from discovery to querying and previewing.
Installation¶
Use the official command to install it:
dsh plugin --profile web add github:xby_skill/xby-toronto-open-data-server
Core Capabilities¶
The plugin provides the following core features, covering the entire data querying workflow:
- set_xby_apikey
Used to set an API key in the conversation. This setting is automatically persisted and remains valid after a restart. - toronto_start_here
This is the starting point for any Toronto data query. It explains how to use the server effectively and provides a complete workflow guide for accessing Toronto Open Data. - toronto_smart_data_helper
This is the most recommended way to handle data. It is a smart helper that accepts a dataset ID and a query description, automatically determines whether the data is API-accessible or requires a CSV download, and returns the relevant data or next-step recommendations. - Dataset Discovery
Includestoronto_list_datasets(lists all datasets),toronto_search_datasets(searches by keywords), andtoronto_popular_datasets(retrieves the list of popular datasets). - Data Querying and Structure
Includestoronto_get_dataset_schema(retrieves field names, IDs, and types for a dataset) andtoronto_query_dataset_data(executes advanced queries with precise filtering, sorting, and field selection). - Data Retrieval
Includestoronto_get_dataset_stats(retrieves record counts, field information, and resource overviews) andtoronto_fetch_csv_data(downloads and returns CSV file content or provides a download link).
Usage Examples¶
1. Initialization and Discovery¶
First, call set_xby_apikey in the conversation to set your key. Then, use toronto_start_here to understand the workflow, or use toronto_search_datasets to find data for a specific topic.
2. Smart Query¶
For most use cases, directly call toronto_smart_data_helper. It accepts a dataset ID and a target description, and automatically handles the subsequent logic.
3. Advanced Query Flow¶
If you need finer control, follow these steps:
- Use
toronto_get_dataset_schema(dataset_id)to obtain field names and types. - Use
toronto_query_dataset_datato run the query, providing precise field names.
// 示例:查询特定条件的记录
{
"filters": {
"establishment_status": "Pass",
"inspection_date": "2024-01-01"
},
"sorts": "inspection_date desc",
"fields": ["name", "address", "score"]
}
4. Handling CSV Data¶
For datasets in CSV format, toronto_query_dataset_data returns a download link instead of query results. In this case, use toronto_fetch_csv_data to retrieve the file content or download it directly.
Notes¶
- Prefer the Smart Assistant:
toronto_smart_data_helperis the recommended method for most use cases, as it simplifies the workflow and handles complex format determination. - CSV File Characteristics: For CSV files, query operations return a download link rather than direct data results.
- Advanced Query Dependency: Before using
toronto_query_dataset_datafor advanced filtering, sorting, or field selection, you must first calltoronto_get_dataset_schemato obtain the correct field names.
Conclusion¶
This plugin provides a standard interface for LLM agents to interact with Toronto Open Data. By combining a smart assistant with structured queries, developers can efficiently retrieve and process Toronto public data. For more details, refer to the plugin directory or GitHub repository.