aishitdharwal commited on
Commit
fee25a4
·
1 Parent(s): 7905c51
Files changed (1) hide show
  1. app.py +21 -1
app.py CHANGED
@@ -1,5 +1,12 @@
1
  import requests
2
  import gradio as gr
 
 
 
 
 
 
 
3
 
4
  def should_play(city):
5
  api_key = "bb5a3b68cd874753bf565453251804"
@@ -8,6 +15,19 @@ def should_play(city):
8
  res = requests.get(url, params=params).json()
9
  condition = res["current"]["condition"]["text"].lower()
10
  decision = "Don't Play Cricket" if "rain" in condition else "Go Play Cricket!"
11
- return f"{city}: {condition.title()} → {decision}"
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  gr.Interface(fn=should_play, inputs="text", outputs="text", title="Cricket Decision App").launch()
 
1
  import requests
2
  import gradio as gr
3
+ from groq import Groq
4
+ import os
5
+
6
+
7
+ def initialize_groq_client():
8
+ """Initialize and return Groq client"""
9
+ return Groq(api_key=os.environ.get("GROQ_API_KEY"))
10
 
11
  def should_play(city):
12
  api_key = "bb5a3b68cd874753bf565453251804"
 
15
  res = requests.get(url, params=params).json()
16
  condition = res["current"]["condition"]["text"].lower()
17
  decision = "Don't Play Cricket" if "rain" in condition else "Go Play Cricket!"
18
+
19
+ client = initialize_groq_client()
20
+ response = client.chat.completions.create(
21
+ model="llama-3.1-8b-instant",
22
+ messages=[
23
+ {"role": "system", "content": "You are an expert cricket coach."},
24
+ {"role": "user", "content": f"This is the weather condition {condition}, should we go to play cricket, answer 'Yes' or 'No'?"}
25
+ ],
26
+ temperature=0.7,
27
+ max_tokens=2000
28
+ )
29
+
30
+ return response.choices[0].message.content
31
+ # return f"{city}: {condition.title()} → {decision}"
32
 
33
  gr.Interface(fn=should_play, inputs="text", outputs="text", title="Cricket Decision App").launch()