amoghsuman commited on
Commit
043a6e1
Β·
verified Β·
1 Parent(s): fd3a45c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -174,7 +174,13 @@ def recommend_batter(over, wickets, runs, target, batter_out, bowler_type, pitch
174
  batter_stats = "\n".join([get_batter_stats(batter, batters_df, venue, bowler_type) for batter in top_batter_names])
175
 
176
  prompt = f"""
177
- Choose the best batter from: {', '.join(top_batter_names)}
 
 
 
 
 
 
178
  Match Context:
179
  - Over: {over}
180
  - Wickets: {wickets}
@@ -185,11 +191,13 @@ def recommend_batter(over, wickets, runs, target, batter_out, bowler_type, pitch
185
  - Pitch Type: {pitch_type}
186
  - Venue: {venue} (Favours: {pitch_favours})
187
  - Opposition: {opposition}
 
188
  Batter Stats:
189
  {batter_stats}
190
- Suggest the most suitable batter and explain the reasoning in 1-2 lines.
 
191
  Batter: <Name>
192
- Justification: <Reasoning>
193
  """
194
  try:
195
  response = client.chat.completions.create(
@@ -233,7 +241,7 @@ with gr.Blocks(title="IPL Batting Decision Maker") as app:
233
  venue.change(fn=update_venue_stats, inputs=venue, outputs=gr.Textbox(label="🏟️ Venue Stats"))
234
 
235
  submit_btn = gr.Button("πŸš€ Suggest Next Batter")
236
- result = gr.Textbox(label="βœ… Recommended Batter & Justification", lines=3)
237
 
238
  submit_btn.click(fn=recommend_batter, inputs=[
239
  over, wickets, runs, target, batter_out, bowler_type, pitch_type, venue, team_b, available_batters
 
174
  batter_stats = "\n".join([get_batter_stats(batter, batters_df, venue, bowler_type) for batter in top_batter_names])
175
 
176
  prompt = f"""
177
+ You are a cricket analyst selecting the best batter from: {', '.join(top_batter_names)} for an IPL 2025 match. Analyze the match context and batter stats to recommend the most suitable batter. Provide a detailed justification (3-4 sentences) that explains why this batter is the best choice, considering:
178
+ - Their role (e.g., anchor, aggressor, finisher) and how it suits the current over, wickets, and required run rate.
179
+ - Specific stats (e.g., average/strike rate vs. {bowler_type}, form, venue performance).
180
+ - Tactical fit against the opposition ({opposition}) and pitch conditions ({pitch_type}, favours {pitch_favours} at {venue}).
181
+ - Game situation (e.g., chasing {target}, {wickets} wickets down, {20-over} overs remaining).
182
+ Ensure the justification is concise, data-driven, and tactically insightful.
183
+
184
  Match Context:
185
  - Over: {over}
186
  - Wickets: {wickets}
 
191
  - Pitch Type: {pitch_type}
192
  - Venue: {venue} (Favours: {pitch_favours})
193
  - Opposition: {opposition}
194
+
195
  Batter Stats:
196
  {batter_stats}
197
+
198
+ Respond in this format:
199
  Batter: <Name>
200
+ Justification: <3-4 sentences of reasoning>
201
  """
202
  try:
203
  response = client.chat.completions.create(
 
241
  venue.change(fn=update_venue_stats, inputs=venue, outputs=gr.Textbox(label="🏟️ Venue Stats"))
242
 
243
  submit_btn = gr.Button("πŸš€ Suggest Next Batter")
244
+ result = gr.Textbox(label="βœ… Recommended Batter & Justification", lines=5)
245
 
246
  submit_btn.click(fn=recommend_batter, inputs=[
247
  over, wickets, runs, target, batter_out, bowler_type, pitch_type, venue, team_b, available_batters