improved UI and UX for the first tabs
Browse files- app.py +51 -49
- mcp_client.py +1 -1
- todo.txt +0 -5
app.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import gradio as gr
|
2 |
-
import time
|
3 |
|
4 |
# Local modules
|
5 |
import fastf1_tools
|
@@ -11,30 +10,58 @@ from utils.constants import (
|
|
11 |
DROPDOWN_SESSION_TYPES,
|
12 |
MARKDOWN_INTRODUCTION,
|
13 |
MARKDOWN_OPENF1_EXAMPLES,
|
14 |
-
OPENF1_TOOL_DESCRIPTION
|
|
|
|
|
15 |
)
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
gr.
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
)
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
iface_event_info = gr.Interface(
|
40 |
fn=fastf1_tools.get_event_info,
|
@@ -107,36 +134,12 @@ iface_constructor_info = gr.Interface(
|
|
107 |
description="Get background information about a specific constructor"
|
108 |
)
|
109 |
|
110 |
-
def timeout_test(seconds: int) -> str:
|
111 |
-
"""
|
112 |
-
A simple function that sleeps for the given amount of seconds.
|
113 |
-
|
114 |
-
Args:
|
115 |
-
seconds (int): The amount of seconds to sleep
|
116 |
-
|
117 |
-
Returns:
|
118 |
-
str: A message indicating the timeout is completed
|
119 |
-
"""
|
120 |
-
time.sleep(seconds)
|
121 |
-
return f"Timeout for {seconds} seconds completed"
|
122 |
-
|
123 |
-
iface_timeout_testing = gr.Interface(
|
124 |
-
fn=timeout_test,
|
125 |
-
inputs=[
|
126 |
-
gr.Number(label="Seconds", value=5, minimum=1, maximum=500)
|
127 |
-
],
|
128 |
-
outputs="text",
|
129 |
-
title="Timeout Testing",
|
130 |
-
description="Test the timeout functionality"
|
131 |
-
)
|
132 |
-
|
133 |
|
134 |
# Create your markdown-only tab using Blocks
|
135 |
with gr.Blocks() as markdown_tab:
|
136 |
gr.Markdown(MARKDOWN_INTRODUCTION)
|
137 |
|
138 |
|
139 |
-
|
140 |
# OpenF1 tools tab
|
141 |
def openf1_tools_tab():
|
142 |
with gr.Blocks() as openf1_tools_tab:
|
@@ -194,8 +197,7 @@ named_interfaces = {
|
|
194 |
"Session Results": iface_session_results,
|
195 |
"Driver Info": iface_driver_info,
|
196 |
"Constructor Info": iface_constructor_info,
|
197 |
-
"OpenF1 Tools": openf1_tools_tab()
|
198 |
-
"Timeout Testing": iface_timeout_testing
|
199 |
}
|
200 |
|
201 |
# Tab names and interfaces
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
# Local modules
|
4 |
import fastf1_tools
|
|
|
10 |
DROPDOWN_SESSION_TYPES,
|
11 |
MARKDOWN_INTRODUCTION,
|
12 |
MARKDOWN_OPENF1_EXAMPLES,
|
13 |
+
OPENF1_TOOL_DESCRIPTION,
|
14 |
+
CONSTRUCTORS_PER_SEASON,
|
15 |
+
DRIVERS_PER_SEASON
|
16 |
)
|
17 |
|
18 |
+
with gr.Blocks() as iface_driver_championship_standings:
|
19 |
+
gr.Markdown("## World Driver Championship Standings\nGet the world driver championship standings for a specific driver. Note that the older data has gaps and may not be entirely complete.")
|
20 |
+
|
21 |
+
with gr.Row():
|
22 |
+
year_input = gr.Number(label="Calendar year", value=CURRENT_YEAR, minimum=1950, maximum=CURRENT_YEAR)
|
23 |
+
driver_dropdown = gr.Dropdown(label="Driver", choices=DRIVERS_PER_SEASON.get(str(year_input.value), []))
|
24 |
+
output_text = gr.Textbox(label="Result")
|
25 |
+
submit_btn = gr.Button("Submit")
|
26 |
+
|
27 |
+
def update_drivers(year):
|
28 |
+
choices = DRIVERS_PER_SEASON.get(str(year), [])
|
29 |
+
return gr.update(choices=choices, value=(choices[0] if choices else None))
|
30 |
+
|
31 |
+
year_input.blur(
|
32 |
+
update_drivers,
|
33 |
+
inputs=year_input,
|
34 |
+
outputs=driver_dropdown
|
35 |
+
)
|
36 |
+
submit_btn.click(
|
37 |
+
fastf1_tools.driver_championship_standings,
|
38 |
+
inputs=[year_input, driver_dropdown],
|
39 |
+
outputs=output_text
|
40 |
+
)
|
41 |
+
|
42 |
+
with gr.Blocks() as iface_constructor_championship_standings:
|
43 |
+
gr.Markdown("## World Constructor Championship Standings\nGet the current/past world constructor championship standings for a specific constructor. Note that the older data has gaps and may not be entirely complete.")
|
44 |
+
|
45 |
+
with gr.Row():
|
46 |
+
year_input = gr.Number(label="Calendar year", value=CURRENT_YEAR, minimum=1950, maximum=CURRENT_YEAR)
|
47 |
+
constructor_dropdown = gr.Dropdown(label="Constructor", choices=CONSTRUCTORS_PER_SEASON.get(str(year_input.value), []))
|
48 |
+
output_text = gr.Textbox(label="Result")
|
49 |
+
submit_btn = gr.Button("Submit")
|
50 |
+
|
51 |
+
def update_constructors(year):
|
52 |
+
choices = CONSTRUCTORS_PER_SEASON.get(str(year), [])
|
53 |
+
return gr.update(choices=choices, value=(choices[0] if choices else None))
|
54 |
+
|
55 |
+
year_input.blur(
|
56 |
+
update_constructors,
|
57 |
+
inputs=year_input,
|
58 |
+
outputs=constructor_dropdown
|
59 |
+
)
|
60 |
+
submit_btn.click(
|
61 |
+
fastf1_tools.constructor_championship_standings,
|
62 |
+
inputs=[year_input, constructor_dropdown],
|
63 |
+
outputs=output_text
|
64 |
+
)
|
65 |
|
66 |
iface_event_info = gr.Interface(
|
67 |
fn=fastf1_tools.get_event_info,
|
|
|
134 |
description="Get background information about a specific constructor"
|
135 |
)
|
136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
|
138 |
# Create your markdown-only tab using Blocks
|
139 |
with gr.Blocks() as markdown_tab:
|
140 |
gr.Markdown(MARKDOWN_INTRODUCTION)
|
141 |
|
142 |
|
|
|
143 |
# OpenF1 tools tab
|
144 |
def openf1_tools_tab():
|
145 |
with gr.Blocks() as openf1_tools_tab:
|
|
|
197 |
"Session Results": iface_session_results,
|
198 |
"Driver Info": iface_driver_info,
|
199 |
"Constructor Info": iface_constructor_info,
|
200 |
+
"OpenF1 Tools": openf1_tools_tab()
|
|
|
201 |
}
|
202 |
|
203 |
# Tab names and interfaces
|
mcp_client.py
CHANGED
@@ -17,7 +17,7 @@ def agent_chat(message: str, history: list):
|
|
17 |
|
18 |
if __name__ == "__main__":
|
19 |
|
20 |
-
list_tools =
|
21 |
local_model = True # If you have Ollama installed, set this to True
|
22 |
|
23 |
try:
|
|
|
17 |
|
18 |
if __name__ == "__main__":
|
19 |
|
20 |
+
list_tools = False # Set to True to only list tools (used for debugging)
|
21 |
local_model = True # If you have Ollama installed, set this to True
|
22 |
|
23 |
try:
|
todo.txt
DELETED
@@ -1,5 +0,0 @@
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|