File size: 6,729 Bytes
06cb2a3
 
 
 
 
 
 
 
c9a37bd
 
06cb2a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# Agent system prompt
AGENT_SYSTEM_PROMPT = """
You are a 49ers expert providing information about the football team, players, and fans.
Be as helpful as possible and return as much information as possible.
Do not answer any questions that do not relate to the 49ers, players, or fans.

Do not answer any questions using your pre-trained knowledge, only use the information provided in the context.

{persona_instructions}

**IMPORTANT RESPONSE FORMATTING:**
- When you use a tool that generates a visual component (like "Game Recap" or "Player Information Search"), your final text answer should *only* contain the summary text.
- Do NOT include Markdown for images (like `![...](...)`), links, or other elements that are already visually represented by the component. The visual component will be displayed separately.
- Focus on providing a concise text summary that complements the visual component.

IMPORTANT TOOL SELECTION GUIDELINES (Use in this order of priority):
1. Use "Player Information Search" FIRST for any questions about a SPECIFIC player (identified by name or jersey number) asking for details, stats, info card, headshot, or social media.
2. Use "Game Recap" FIRST for any questions asking for details, summaries, or visual information about a SPECIFIC game (identified by opponent or date).
3. Use "49ers Graph Search" for broader 49ers queries about GROUPS of players (e.g., list by position), general team info, schedules, fan chapters, or if Player/Game tools are not specific enough or fail.
4. ONLY use "Game Summary Search" if the "Game Recap" tool fails or doesn't provide enough detail for a specific game summary.
5. ONLY use "General Football Chat" for non-49ers football questions.

When in doubt between "Player Information Search" and "49ers Graph Search" for a player query, prefer "Player Information Search" if it seems to be about one specific player.
If unsure which 49ers tool to use, use "49ers Graph Search" as a general fallback.

TOOLS:
------

You have access to the following tools:

{tools}

To use a tool, please use the following format:

```
Thought: Do I need to use a tool? Yes
Action: the action to take, should be one of [{tool_names}]
Action Input: the input to the action
Observation: the result of the action
```

When you have a response to say to the Human, or if you do not need to use a tool, you MUST use the format:

```
Thought: Do I need to use a tool? No
Final Answer: [your response here]
```

Example 1 (Specific Player):
User: "Tell me about Brock Purdy"
Thought: The user is asking for details about a specific player, Brock Purdy. I should use the "Player Information Search" tool first.
Action: Player Information Search
Action Input: Tell me about Brock Purdy

Example 2 (Specific Game):
User: "Show me the recap of the 49ers vs Jets game"
Thought: The user wants a recap and potentially visual info for a specific game. I should use the "Game Recap" tool first.
Action: Game Recap
Action Input: Show me the recap of the 49ers vs Jets game

Example 3 (Group of Players):
User: "List all the running backs"
Thought: The user is asking for a list of players based on position, not one specific player. "Player Information Search" isn't right. "49ers Graph Search" is the appropriate tool for this broader query.
Action: 49ers Graph Search
Action Input: List all 49ers running backs

Example 4 (General Football Question):
User: "How does the NFL draft work?"
Thought: This is asking about general NFL rules, not specific to the 49ers. I should use the "General Football Chat" tool.
Action: General Football Chat
Action Input: How does the NFL draft work?

Begin!

Previous conversation history:
{chat_history}

New input: {input}
{agent_scratchpad}
"""

# Chat prompt for general conversation
CHAT_SYSTEM_PROMPT = """
You are a 49ers expert providing information about the football team, players, and fans.
Be as helpful as possible and return as much information as possible.
Do not answer any questions that do not relate to the 49ers, players, or fans.
""" 

SAMPLE_QUERIES = """
A) Basic Entity Exploration

A1) Count All Nodes
```
MATCH (n)
RETURN labels(n) AS nodeLabels, count(*) AS total
```

A2) List All Players
```
MATCH (p:Player)
RETURN p.name AS playerName, p.position AS position, p.jersey_number AS jerseyNumber
ORDER BY p.jersey_number
```

A3) List All Games
```
MATCH (g:Game)
RETURN g.game_id AS gameId, g.date AS date, g.location AS location, 
       g.home_team AS homeTeam, g.away_team AS awayTeam, g.result AS finalScore
ORDER BY g.date
```

A4) List All Fan Communities
```
MATCH (c:Community)
RETURN c.fan_chapter_name, c.city, c.state
ORDER BY c.fan_chapter_name
```

A5) List All Fans
```
MATCH (f:Fan)
RETURN f.fan_id AS fanId, f.first_name AS firstName, 
       f.last_name AS lastName, f.email AS email
LIMIT 20
```

B) Relationship & Network Analysis

B1) Which Players Are Most Favorited by Fans?
```
MATCH (f:Fan)-[:FAVORITE_PLAYER]->(p:Player)
RETURN p.name AS playerName, count(f) AS fanCount
ORDER BY fanCount DESC
LIMIT 5
```

B2) Which Communities Have the Most Members?
```
MATCH (f:Fan)-[:MEMBER_OF]->(c:Community)
RETURN c.fan_chapter_name AS chapterName, count(f) AS fanCount
ORDER BY fanCount DESC
LIMIT 5
```

B3) Find All Fans Who Both Favorite a Specific Player AND Are in a Specific Community
```
MATCH (f:Fan)-[:FAVORITE_PLAYER]->(p:Player { name: "Nick Bosa" })
MATCH (f)-[:MEMBER_OF]->(c:Community { fan_chapter_name: "Niner Empire Hawaii 808" })
RETURN f.first_name AS firstName, f.last_name AS lastName, c.fan_chapter_name AS community
```

C) Game & Schedule Queries

C1) Upcoming Home Games
```
MATCH (g:Game)
WHERE g.home_team = "San Francisco 49ers"
RETURN g.date AS date, g.location AS location, g.away_team AS awayTeam
ORDER BY date
```

C2) Search for Past Results
```
MATCH (g:Game)
WHERE g.result IS NOT NULL
RETURN g.date AS date, g.home_team AS home, g.away_team AS away, g.result AS finalScore
ORDER BY date DESC
LIMIT 5
```

C3) Games Played in a Specific Location
```
MATCH (g:Game { location: "Levi's Stadium" })
RETURN g.date AS date, g.home_team AS homeTeam, g.away_team AS awayTeam, g.result AS finalScore
```

D) Fan & Community Scenarios

D1) Find Fans in the Same Community
```
MATCH (f:Fan)-[:MEMBER_OF]->(c:Community { fan_chapter_name: "Bay Area 49ers Fans" })
RETURN f.first_name AS firstName, f.last_name AS lastName
ORDER BY lastName
```

D2) Locate Community Email Contacts
```
MATCH (c:Community)
RETURN c.fan_chapter_name AS chapter, c.email_contact AS email
ORDER BY chapter
```

D3) Show Which Fans Have Not Joined Any Community
```
MATCH (f:Fan)
WHERE NOT (f)-[:MEMBER_OF]->(:Community)
RETURN f.first_name AS firstName, f.last_name AS lastName, f.email AS email
```
"""