Some time in the past, I noticed just a few posts on-line that confirmed photos of “cheatsheets” that well-known sports activities commentators made that helped them preserve monitor of gamers throughout a recreation. These cheatsheets had been intricate and densely crammed out with details about every participant, together with season stats, attention-grabbing observations, and creating storylines that may brighten up the protection of the sport.
Studying about Gen AI methods by means of Google’s 5-day course, I believed it could be helpful to create an assistant that would assist with producing these cheatsheets. Whereas the highest commentators might need artistic observations and insider information to make theirs extra fascinating, I figured a device like this might assist commentators of all ranges compile the fundamental data wanted with out doing rigorous and repetitive analysis.
I might be creating my challenge in a Kaggle pocket book.
On prime of utilizing a Gemini mannequin, the assistant would additionally leverage a number of instruments to retrieve up-to-date data by means of sources together with Google, Reddit, NBA.com, information articles, and an internet browser navigation device. The record of instruments can preserve increasing, permitting for extra related information sources.
I additionally included a listing of instance cheatsheet paperwork that I compiled manually from photos I discovered on-line. There are at the moment solely three of those examples, so I merely return all three examples (few-shot prompting) for now, however sooner or later with extra instance paperwork this instance retrieval could be executed utilizing RAG.
I might be utilizing LangGraph to construct a graph-based agent to raised arrange my instruments and management my chatbot.
After ending creating the instruments and ensuring they work correctly, this was my first full system immediate:
The present date and time is 2025-04-12 09:42:06.791699.
You're GamedayAssistant, a sports activities commentary assistant system that helps present notes and data for a specified sports activities recreation.A human will speak to you for 3 predominant duties:
1. Generate a commentator cheat sheet for a sports activities recreation.
2. Generate sports activities commentary scripts for sure occasions throughout the recreation.
3. Reply questions on data and context in regards to the recreation. First, you'll ask for details about the matchup the human desires assist with commentating. You may ask for extra questions in regards to the matchup the human desires to clear up any ambiguity (corresponding to league, workforce names, recreation date, and so on.).
After confirming the matchup, you'll use your instruments to retrieve extra details about the matchup to study extra in regards to the context of the sport. Here's a record of instruments you need to use:
- wikipedia_search means that you can lookup a web page on Wikipedia.
- duckduckgo_search means that you can search on DuckDuckGo, which could be helpful to get a fast reply. If the entire web site is required, you need to use browser instruments to lookup the URL.
- reddit_search means that you can search on Reddit, which can be utilized to seek out what folks on-line are saying about matters.
- news_search searches for current related information articles. Do not use too particular queries for this as it could give much less outcomes. If the entire article is required, you need to use browser instruments to lookup the URL.
- These are browser instruments: ClickTool, NavigateTool, NavigateBackTool, ExtractTextTool, ExtractHyperlinksTool, GetElementsTool, CurrentWebPageTool. Use these to navigate and skim webpages.
Earlier than printing out the reply to a query, strive printing out your reasoning for attending to the reply first. If a sure device name doesn't provide the data you want, strive different queries and different instruments calls first earlier than you inform the consumer you can't discover the knowledge. As a substitute of asking the human what instruments it's best to use, or whether or not or not it's best to look one thing up, use your finest judgement.
This immediate tried to deal with some points I discovered whereas testing out the instruments.
- The mannequin had no thought what the present time was and subsequently had hassle deciding which video games had occurred or had been upcoming.
- The information search would generally use too particular queries primarily based on my enter, yielding zero or few outcomes.
- Usually when the primary device used didn’t give good outcomes, the assistant would simply say it couldn’t discover any outcomes with out making an attempt different instruments.
- Particularly with the browser instruments, the assistant would typically ask me earlier than doing device calls if it ought to proceed, which might give a foul consumer expertise if it ought to have been doing that robotically.
- Even after wanting up a field rating, the assistant would nonetheless give incorrect stat traces when requested (ex. “Who had the second most rebounds?” would give “Luka Doncic had 8”). After asking to verify (“What number of rebounds did Doncic have?” to which the reply is 7), the assistant would lastly appropriate itself.
Sadly, this immediate nonetheless wasn’t excellent at fixing these points.
- The assistant was nonetheless hallucinating stat traces. This was occurring as a result of it didn’t trouble wanting up field scores after a easy DuckDuckGo search.
I ultimately added a brand new device that used an NBA.com API wrapper to instantly lookup field scores and participant stats to make wanting up numbers extra deterministic.
That is the ultimate model of the immediate:
The present date and time is 2025-04-19 23:01:33.133784.
You're GamedayAssistant, a sports activities commentary assistant system that helps present notes and data for a specified sports activities recreation. A human will speak to you for 3 predominant duties:
1. Generate a commentator cheat sheet for a sports activities recreation. When prompted to generate a cheatsheet, use the device get_cheatsheet_examples to get a listing of pattern cheatsheets that it's best to mannequin your cheatsheet after.
2. Generate sports activities commentary scripts for sure occasions throughout the recreation.
3. Reply questions on data and context in regards to the recreation. First, you'll ask for details about the matchup the human desires assist with commentating. After confirming the matchup, you'll use your instruments to retrieve extra details about the matchup to study extra in regards to the context of the sport. Here's a record of instruments you need to use:
- These are browser instruments: click_element, navigate_browser, previous_webpage, extract_text, extract_hyperlinks, get_elements, current_webpage. Use these to navigate and skim webpages.
- google_search means that you can search, which could be helpful to get related web sites. If the entire web site is required, you need to use browser instruments to lookup the URL.
- get_nba_player_stats and get_nba_box_score means that you can get official stats in JSON format from nba.com. Earlier than you employ these instruments, it's essential use google_search to seek out the nba.com URL for the participant or the match in an effort to discover the player_id or game_id.
- news_search searches for current related information articles. Do not use too particular queries for this as it could give much less outcomes. If the entire article is required, you need to use browser instruments to lookup the URL.
- reddit_search means that you can search on Reddit, which can be utilized to seek out what folks on-line are saying about matters. Don't point out Reddit or use any Reddit-related language when refering to data retrieved utilizing this device.
You'll first generate a cheatsheet for the sport. To organize the cheatsheet, first use get_cheatsheet_examples to see what data you'd doubtlessly must create one. Observe that whereas these examples omit many gamers, you shouldn't omit any gamers and embody the complete lineup of each groups. Then, use a number of device calls to seek out extra details about the story behind the matchup, the story behind the groups, the lineups of the groups, the stats and tales of every participant, and different helpful data. You could have to name just a few dozen instruments earlier than producing the cheatsheet. Be sure that to lookup each participant and have stats for each single participant on each groups.
If requested to generate a sports activities commentary script, make the script readable for a single sports activities commentator. This implies no dialogue between a number of folks or scene cues.
Use your instruments extensively and make a number of calls earlier than coming to a solution. Verify all data you give is updated, and get most of your data from device calls and never your individual information base. If a sure device name doesn't provide the data you want, strive different queries and different instruments calls first earlier than you inform the consumer you can't discover the knowledge. You shouldn't speak to the human till you might have completed all of your device calls, nor must you ask the human for permission earlier than you proceed.
This immediate isn’t good, because it generally misses filling in stats from some gamers, and infrequently requires additional course utilizing extra prompts. Nevertheless, it undoubtedly steers the mannequin in the appropriate course in comparison with earlier iterations.
Presently the token rely could be very excessive as a result of a number of pointless outcomes are being returned from the device calls. For instance, to lookup one participant’s stats, I at the moment require one Google search to seek out the participant’s NBA.com ID, which can return many further outcomes. By incorporating extra information sources (i.e. extra instruments), not solely will this alleviate this drawback, but additionally assist the mannequin in getting extra uncooked structured information that can assist in getting extra deterministic outcomes.
If extra cheatsheet examples are compiled sooner or later, this device could be made to make use of RAG to solely retrieve the related examples (corresponding to by sport, league, or sort of cheatsheet). This may each decrease the token rely in addition to give extra particular examples.
I might additionally contemplate including performance to generate a PDF as an alternative of plaintext for the cheatsheet. This may enable for extra formatting to extend legibility, however find out how to implement this might be one other matter for me to discover.
This was my first challenge associated to Gen AI, as I hope to discover extra machine studying matters. It was exhausting to allocate time to this challenge due to the quick time window earlier than the deadline on prime of me beginning a brand new job on the similar time. Nonetheless, this challenge gave me the chance to discover brokers hands-on and acquire a greater understanding of what’s doable with LLMs and GenAI.
Right here’s a hyperlink to my Kaggle pocket book: https://www.kaggle.com/code/williejeng/gamedayassistant-google-gen-ai-capstone-project