removed intermediate function for OpenF1 Gradio tools. Now the display name for the MCP tools should be correct in the MCP host
Browse files- app.py +7 -26
- todo.txt +3 -1
- utils/constants.py +2 -1
app.py
CHANGED
@@ -120,61 +120,42 @@ def openf1_tools_tab():
|
|
120 |
with gr.Accordion("get_api_endpoints()", open=False):
|
121 |
btn = gr.Button("Get all endpoints")
|
122 |
output = gr.JSON()
|
123 |
-
|
124 |
-
return openf1_tools.get_api_endpoints()
|
125 |
-
btn.click(_get_api_endpoints, outputs=output)
|
126 |
with gr.Accordion("get_api_endpoint(endpoint)", open=False):
|
127 |
endpoint_in = gr.Textbox(label="Endpoint", placeholder="e.g. sessions")
|
128 |
btn = gr.Button("Get endpoint info")
|
129 |
output = gr.JSON()
|
130 |
-
|
131 |
-
return openf1_tools.get_api_endpoint(endpoint)
|
132 |
-
btn.click(_get_api_endpoint, inputs=endpoint_in, outputs=output)
|
133 |
with gr.Accordion("get_endpoint_info(endpoint)", open=False):
|
134 |
endpoint_in = gr.Textbox(label="Endpoint", placeholder="e.g. sessions")
|
135 |
btn = gr.Button("Get endpoint details")
|
136 |
output = gr.JSON()
|
137 |
-
|
138 |
-
return openf1_tools.get_endpoint_info(endpoint)
|
139 |
-
btn.click(_get_endpoint_info, inputs=endpoint_in, outputs=output)
|
140 |
with gr.Accordion("get_filter_info(filter_name)", open=False):
|
141 |
filter_in = gr.Textbox(label="Filter name", placeholder="e.g. driver_number")
|
142 |
btn = gr.Button("Get filter info")
|
143 |
output = gr.JSON()
|
144 |
-
|
145 |
-
return openf1_tools.get_filter_info(filter_name)
|
146 |
-
btn.click(_get_filter_info, inputs=filter_in, outputs=output)
|
147 |
with gr.Accordion("get_filter_string(filter_name, filter_value, operator)", open=False):
|
148 |
filter_name = gr.Textbox(label="Filter name", placeholder="e.g. driver_number")
|
149 |
filter_value = gr.Textbox(label="Filter value", placeholder="e.g. 16")
|
150 |
operator = gr.Dropdown(label="Operator", choices=["=", ">", "<", ">=", "<="], value="=")
|
151 |
btn = gr.Button("Get filter string")
|
152 |
output = gr.Textbox(label="Filter string", info="Example: driver_number=16&")
|
153 |
-
|
154 |
-
return openf1_tools.get_filter_string(filter_name, filter_value, operator)
|
155 |
-
btn.click(_get_filter_string, inputs=[filter_name, filter_value, operator], outputs=output)
|
156 |
with gr.Accordion("apply_filters(api_string, *filters)", open=False):
|
157 |
api_string = gr.Textbox(label="Base API string", placeholder="e.g. https://api.openf1.org/v1/sessions?")
|
158 |
filters = gr.Textbox(label="Filters (comma-separated)", placeholder="e.g. driver_number=16&,session_key=123&")
|
159 |
btn = gr.Button("Apply filters")
|
160 |
output = gr.Textbox(label="Full API string")
|
161 |
-
|
162 |
-
# Expect filters as comma-separated
|
163 |
-
filter_list = [f.strip() for f in filters.split(",") if f.strip()]
|
164 |
-
return openf1_tools.apply_filters(api_string, *filter_list)
|
165 |
-
btn.click(_apply_filters, inputs=[api_string, filters], outputs=output)
|
166 |
with gr.Accordion("send_request(api_string)", open=False):
|
167 |
with gr.Accordion("Example API requests (copy & paste into text box below)", open=False):
|
168 |
gr.Markdown(MARKDOWN_OPENF1_EXAMPLES)
|
169 |
api_string = gr.Textbox(label="Full API string", placeholder="e.g. https://api.openf1.org/v1/sessions?driver_number=16")
|
170 |
btn = gr.Button("Send API request")
|
171 |
output = gr.JSON()
|
172 |
-
|
173 |
-
try:
|
174 |
-
return openf1_tools.send_request(api_string)
|
175 |
-
except Exception as e:
|
176 |
-
return {"error": str(e)}
|
177 |
-
btn.click(_send_request, inputs=api_string, outputs=output)
|
178 |
return openf1_tools_tab
|
179 |
|
180 |
# OpenF1 tabs
|
|
|
120 |
with gr.Accordion("get_api_endpoints()", open=False):
|
121 |
btn = gr.Button("Get all endpoints")
|
122 |
output = gr.JSON()
|
123 |
+
btn.click(openf1_tools.get_api_endpoints, outputs=output)
|
|
|
|
|
124 |
with gr.Accordion("get_api_endpoint(endpoint)", open=False):
|
125 |
endpoint_in = gr.Textbox(label="Endpoint", placeholder="e.g. sessions")
|
126 |
btn = gr.Button("Get endpoint info")
|
127 |
output = gr.JSON()
|
128 |
+
btn.click(openf1_tools.get_api_endpoint, inputs=endpoint_in, outputs=output)
|
|
|
|
|
129 |
with gr.Accordion("get_endpoint_info(endpoint)", open=False):
|
130 |
endpoint_in = gr.Textbox(label="Endpoint", placeholder="e.g. sessions")
|
131 |
btn = gr.Button("Get endpoint details")
|
132 |
output = gr.JSON()
|
133 |
+
btn.click(openf1_tools.get_endpoint_info, inputs=endpoint_in, outputs=output)
|
|
|
|
|
134 |
with gr.Accordion("get_filter_info(filter_name)", open=False):
|
135 |
filter_in = gr.Textbox(label="Filter name", placeholder="e.g. driver_number")
|
136 |
btn = gr.Button("Get filter info")
|
137 |
output = gr.JSON()
|
138 |
+
btn.click(openf1_tools.get_filter_info, inputs=filter_in, outputs=output)
|
|
|
|
|
139 |
with gr.Accordion("get_filter_string(filter_name, filter_value, operator)", open=False):
|
140 |
filter_name = gr.Textbox(label="Filter name", placeholder="e.g. driver_number")
|
141 |
filter_value = gr.Textbox(label="Filter value", placeholder="e.g. 16")
|
142 |
operator = gr.Dropdown(label="Operator", choices=["=", ">", "<", ">=", "<="], value="=")
|
143 |
btn = gr.Button("Get filter string")
|
144 |
output = gr.Textbox(label="Filter string", info="Example: driver_number=16&")
|
145 |
+
btn.click(openf1_tools.get_filter_string, inputs=[filter_name, filter_value, operator], outputs=output)
|
|
|
|
|
146 |
with gr.Accordion("apply_filters(api_string, *filters)", open=False):
|
147 |
api_string = gr.Textbox(label="Base API string", placeholder="e.g. https://api.openf1.org/v1/sessions?")
|
148 |
filters = gr.Textbox(label="Filters (comma-separated)", placeholder="e.g. driver_number=16&,session_key=123&")
|
149 |
btn = gr.Button("Apply filters")
|
150 |
output = gr.Textbox(label="Full API string")
|
151 |
+
btn.click(openf1_tools.apply_filters, inputs=[api_string, filters], outputs=output)
|
|
|
|
|
|
|
|
|
152 |
with gr.Accordion("send_request(api_string)", open=False):
|
153 |
with gr.Accordion("Example API requests (copy & paste into text box below)", open=False):
|
154 |
gr.Markdown(MARKDOWN_OPENF1_EXAMPLES)
|
155 |
api_string = gr.Textbox(label="Full API string", placeholder="e.g. https://api.openf1.org/v1/sessions?driver_number=16")
|
156 |
btn = gr.Button("Send API request")
|
157 |
output = gr.JSON()
|
158 |
+
btn.click(openf1_tools.send_request, inputs=api_string, outputs=output)
|
|
|
|
|
|
|
|
|
|
|
159 |
return openf1_tools_tab
|
160 |
|
161 |
# OpenF1 tabs
|
todo.txt
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
- For driver championship standings, make the Driver dropdown depend on the selected season. As it is implemented now one could not use it for older seasons!
|
2 |
* Solution is to have a static json file that maps drivers for each season/year
|
3 |
- Same applies for constructor championship standings but instead Constructor dropdown
|
4 |
-
* Similar solution to above
|
|
|
|
|
|
1 |
- For driver championship standings, make the Driver dropdown depend on the selected season. As it is implemented now one could not use it for older seasons!
|
2 |
* Solution is to have a static json file that maps drivers for each season/year
|
3 |
- Same applies for constructor championship standings but instead Constructor dropdown
|
4 |
+
* Similar solution to above
|
5 |
+
- Add driver comparison
|
6 |
+
- simplify the mcp_client.py to single call.
|
utils/constants.py
CHANGED
@@ -106,7 +106,8 @@ Each of these endpoints have different **_filters_** that can be used to filter
|
|
106 |
|
107 |
The implemented functions make it possible to:
|
108 |
- Get all available endpoints - `get_api_endpoints()`
|
109 |
-
- Get
|
|
|
110 |
- Get information about a specific filter - `get_filter_info(filter_name)`
|
111 |
- Get a filter string for a specific filter - `get_filter_string(filter_name, filter_value, operator)`
|
112 |
- Apply filters to an API string - `apply_filters(api_string, *filters)`
|
|
|
106 |
|
107 |
The implemented functions make it possible to:
|
108 |
- Get all available endpoints - `get_api_endpoints()`
|
109 |
+
- Get api string for a specific endpoint - `get_api_endpoint(endpoint)`
|
110 |
+
- Get details about a specific endpoint - `get_endpoint_info(endpoint)`
|
111 |
- Get information about a specific filter - `get_filter_info(filter_name)`
|
112 |
- Get a filter string for a specific filter - `get_filter_string(filter_name, filter_value, operator)`
|
113 |
- Apply filters to an API string - `apply_filters(api_string, *filters)`
|