added comments for openf1 in about tag, improved UI for some of the fastf1 tabs
Browse files- app.py +2 -2
- fastf1_tools.py +2 -2
- todo.txt +0 -1
- utils/constants.py +10 -7
app.py
CHANGED
|
@@ -68,7 +68,7 @@ iface_event_info = gr.Interface(
|
|
| 68 |
inputs=[
|
| 69 |
gr.Number(label="Calendar year", value=CURRENT_YEAR, minimum=1950, maximum=CURRENT_YEAR),
|
| 70 |
gr.Textbox(label="Grand Prix", placeholder="Ex: Monaco", info="The name of the GP/country/location (Fuzzy matching supported) or round number"),
|
| 71 |
-
gr.Radio(["human", "LLM"], label="Display format", value="human")
|
| 72 |
],
|
| 73 |
outputs="text",
|
| 74 |
title="Event Info",
|
|
@@ -94,7 +94,7 @@ iface_track_visualization = gr.Interface(
|
|
| 94 |
],
|
| 95 |
outputs="image",
|
| 96 |
title="Track Visualizations",
|
| 97 |
-
description="Get the track visualization (speed/corners/gear) for the
|
| 98 |
)
|
| 99 |
|
| 100 |
iface_session_results = gr.Interface(
|
|
|
|
| 68 |
inputs=[
|
| 69 |
gr.Number(label="Calendar year", value=CURRENT_YEAR, minimum=1950, maximum=CURRENT_YEAR),
|
| 70 |
gr.Textbox(label="Grand Prix", placeholder="Ex: Monaco", info="The name of the GP/country/location (Fuzzy matching supported) or round number"),
|
| 71 |
+
gr.Radio(["human", "LLM"], label="Display format", value="human", info="Toggle between human-readable (parsed) and LLM output (raw)")
|
| 72 |
],
|
| 73 |
outputs="text",
|
| 74 |
title="Event Info",
|
|
|
|
| 94 |
],
|
| 95 |
outputs="image",
|
| 96 |
title="Track Visualizations",
|
| 97 |
+
description="Get the track visualization (speed/corners/gear) for the fastest lap at the specific Grand Prix race. Example: (2025,Monaco,speed)"
|
| 98 |
)
|
| 99 |
|
| 100 |
iface_session_results = gr.Interface(
|
fastf1_tools.py
CHANGED
|
@@ -132,7 +132,7 @@ def driver_championship_standings(year: int, driver_name: str) -> str:
|
|
| 132 |
return f"Could not find stats for {driver_name}"
|
| 133 |
suffix = "st" if driver_standing['position'].iloc[0] == 1 else "nd" if driver_standing['position'].iloc[0] == 2 else "rd" if driver_standing['position'].iloc[0] == 3 else "th"
|
| 134 |
is_was = "is" if year == CURRENT_YEAR else "was"
|
| 135 |
-
standings_string = f"{driver_name} {is_was} {driver_standing['position'].iloc[0]}{suffix} with {driver_standing['points'].iloc[0]} points and {driver_standing['wins'].iloc[0]} wins"
|
| 136 |
return standings_string
|
| 137 |
|
| 138 |
def constructor_championship_standings(year: int, constructor_name: str) -> str:
|
|
@@ -152,7 +152,7 @@ def constructor_championship_standings(year: int, constructor_name: str) -> str:
|
|
| 152 |
constructor_standing = constructor_standing[constructor_standing["constructorName"] == constructor_name]
|
| 153 |
suffix = "st" if constructor_standing['position'].iloc[0] == 1 else "nd" if constructor_standing['position'].iloc[0] == 2 else "rd" if constructor_standing['position'].iloc[0] == 3 else "th"
|
| 154 |
are_were = "are" if year == CURRENT_YEAR else "were"
|
| 155 |
-
standings_string = f"{constructor_name} {are_were} {constructor_standing['position'].iloc[0]}{suffix} with {constructor_standing['points'].iloc[0]} points and {constructor_standing['wins'].iloc[0]} wins"
|
| 156 |
return standings_string
|
| 157 |
|
| 158 |
def track_visualization(year: int, round: gp, visualization_type: str) -> Image.Image:
|
|
|
|
| 132 |
return f"Could not find stats for {driver_name}"
|
| 133 |
suffix = "st" if driver_standing['position'].iloc[0] == 1 else "nd" if driver_standing['position'].iloc[0] == 2 else "rd" if driver_standing['position'].iloc[0] == 3 else "th"
|
| 134 |
is_was = "is" if year == CURRENT_YEAR else "was"
|
| 135 |
+
standings_string = f"{driver_name} {is_was} {int(driver_standing['position'].iloc[0])}{suffix} with {int(driver_standing['points'].iloc[0])} points and {int(driver_standing['wins'].iloc[0])} wins"
|
| 136 |
return standings_string
|
| 137 |
|
| 138 |
def constructor_championship_standings(year: int, constructor_name: str) -> str:
|
|
|
|
| 152 |
constructor_standing = constructor_standing[constructor_standing["constructorName"] == constructor_name]
|
| 153 |
suffix = "st" if constructor_standing['position'].iloc[0] == 1 else "nd" if constructor_standing['position'].iloc[0] == 2 else "rd" if constructor_standing['position'].iloc[0] == 3 else "th"
|
| 154 |
are_were = "are" if year == CURRENT_YEAR else "were"
|
| 155 |
+
standings_string = f"{constructor_name} {are_were} {int(constructor_standing['position'].iloc[0])}{suffix} with {int(constructor_standing['points'].iloc[0])} points and {int(constructor_standing['wins'].iloc[0])} wins"
|
| 156 |
return standings_string
|
| 157 |
|
| 158 |
def track_visualization(year: int, round: gp, visualization_type: str) -> Image.Image:
|
todo.txt
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
- host agent using Modal labs
|
| 2 |
-
- Add some more documentation
|
| 3 |
- Record demonstration using Loom and add link to README
|
| 4 |
* Demo the Gradio UI
|
| 5 |
* Demo the MCP client using Claude Desktop
|
|
|
|
| 1 |
- host agent using Modal labs
|
|
|
|
| 2 |
- Record demonstration using Loom and add link to README
|
| 3 |
* Demo the Gradio UI
|
| 4 |
* Demo the MCP client using Claude Desktop
|
utils/constants.py
CHANGED
|
@@ -36,25 +36,28 @@ DRIVERS_PER_SEASON: dict[int, list[str]] = json.load(open("assets/drivers_per_se
|
|
| 36 |
MARKDOWN_INTRODUCTION = """
|
| 37 |
# π Formula 1 MCP server ποΈ
|
| 38 |
|
| 39 |
-
Welcome to the Formula 1 MCP server, your one-stop destination for
|
| 40 |
<br>
|
| 41 |
-
This application leverages the FastF1 library to provide detailed insights into Formula 1 races, drivers, and teams.
|
| 42 |
|
| 43 |
## Available Tools in Gradio UI
|
| 44 |
|
| 45 |
### Championship Standings
|
| 46 |
-
- **Driver
|
| 47 |
-
- **Constructor
|
| 48 |
|
| 49 |
### Race Information
|
| 50 |
-
- **Event Info**: Get detailed information about specific Grand Prix
|
| 51 |
- **Season Calendar**: View the complete race calendar for any season
|
| 52 |
- **Session Results**: Access race, qualifying, and sprint session results
|
| 53 |
|
| 54 |
### Driver & Team Data
|
| 55 |
-
- **Driver Info**:
|
| 56 |
-
- **
|
|
|
|
| 57 |
|
|
|
|
|
|
|
| 58 |
|
| 59 |
## Usage
|
| 60 |
|
|
|
|
| 36 |
MARKDOWN_INTRODUCTION = """
|
| 37 |
# π Formula 1 MCP server ποΈ
|
| 38 |
|
| 39 |
+
Welcome to the Formula 1 MCP server, your one-stop destination for Formula 1 data retrieval and race real-time race strategy analysis.
|
| 40 |
<br>
|
| 41 |
+
This application leverages the FastF1 library and OpenF1 API to provide detailed insights into Formula 1 races, drivers, and teams.
|
| 42 |
|
| 43 |
## Available Tools in Gradio UI
|
| 44 |
|
| 45 |
### Championship Standings
|
| 46 |
+
- **Driver Standings**: Retrieve live or past driver championship standings for a specific driver
|
| 47 |
+
- **Constructor Standings**: Retrieve live or past constructor championship standings for a specific constructor
|
| 48 |
|
| 49 |
### Race Information
|
| 50 |
+
- **Event Info**: Get detailed information about a specific Grand Prix event
|
| 51 |
- **Season Calendar**: View the complete race calendar for any season
|
| 52 |
- **Session Results**: Access race, qualifying, and sprint session results
|
| 53 |
|
| 54 |
### Driver & Team Data
|
| 55 |
+
- **Driver Info**: Retrieve detailed driver information from the 2025 Formula 1 season
|
| 56 |
+
- **Constructor Info**: Retrieve detailed constructor information from the 2025 Formula 1 season
|
| 57 |
+
- **Track Visualizations**: Explore interactive track maps with speed, gear, and corner visualizations
|
| 58 |
|
| 59 |
+
### OpenF1 Tools
|
| 60 |
+
- **OpenF1 Tools**: Access the OpenF1 API directly within the MCP server, allowing a LLM to interact with the API using natural language.
|
| 61 |
|
| 62 |
## Usage
|
| 63 |
|