Commit
·
2b6ca1f
1
Parent(s):
8ceffe3
Update server
Browse filesSigned-off-by: Aivin V. Solatorio <avsolatorio@gmail.com>
- wdi_mcp_server.py +11 -6
wdi_mcp_server.py
CHANGED
@@ -114,7 +114,9 @@ class DetailedOutput(SearchOutput):
|
|
114 |
|
115 |
|
116 |
@mcp.tool()
|
117 |
-
async def search_relevant_indicators(
|
|
|
|
|
118 |
"""Search for a shortlist of relevant indicators from the World Development Indicators (WDI) given the query. The search ranking may not be optimal, so the LLM may use this as shortlist and pick the most relevant from the list (if any).
|
119 |
|
120 |
Args:
|
@@ -122,13 +124,16 @@ async def search_relevant_indicators(query: str, top_k: int = 1) -> list[SearchO
|
|
122 |
top_k: The number of shortlisted indicators that will be returned that are semantically related to the query.
|
123 |
|
124 |
Returns:
|
125 |
-
|
126 |
"""
|
127 |
|
128 |
-
return
|
129 |
-
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
132 |
|
133 |
|
134 |
@mcp.tool()
|
|
|
114 |
|
115 |
|
116 |
@mcp.tool()
|
117 |
+
async def search_relevant_indicators(
|
118 |
+
query: str, top_k: int = 1
|
119 |
+
) -> dict[str, list[SearchOutput] | str]:
|
120 |
"""Search for a shortlist of relevant indicators from the World Development Indicators (WDI) given the query. The search ranking may not be optimal, so the LLM may use this as shortlist and pick the most relevant from the list (if any).
|
121 |
|
122 |
Args:
|
|
|
124 |
top_k: The number of shortlisted indicators that will be returned that are semantically related to the query.
|
125 |
|
126 |
Returns:
|
127 |
+
A dictionary with keys `indicators` and `note`. The `indicators` key contains a list of indicator objects with keys indicator code/idno and name. The `note` key contains a note about the search.
|
128 |
"""
|
129 |
|
130 |
+
return {
|
131 |
+
"indicators": [
|
132 |
+
SearchOutput(**out)
|
133 |
+
for out in get_top_k(query=query, top_k=top_k, fields=["idno", "name"])
|
134 |
+
],
|
135 |
+
"note": "IMPORTANT: Let the user know that the search is not exhaustive. The search is based on the semantic similarity of the query to the indicator definitions. It may not be optimal and the LLM may use this as shortlist and pick the most relevant from the list (if any).",
|
136 |
+
}
|
137 |
|
138 |
|
139 |
@mcp.tool()
|