Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,27 @@
|
|
1 |
import gradio as gr
|
2 |
-
import openai
|
3 |
-
import requests
|
4 |
-
from deep_translator import GoogleTranslator
|
5 |
import os
|
|
|
|
|
6 |
|
7 |
-
# Set up
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
MLB_API_URL = "https://api.mlb.com/v1/games/" # Example; replace with actual URL
|
12 |
|
13 |
def get_highlight_summary(team, player, lang='en'):
|
14 |
-
#
|
15 |
highlight = f"Highlight of {player} from {team} in the latest game..."
|
16 |
|
17 |
-
#
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
22 |
)
|
23 |
-
|
|
|
|
|
24 |
|
25 |
# Translate summary if necessary
|
26 |
if lang != 'en':
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
import os
|
3 |
+
from groq import Groq
|
4 |
+
from deep_translator import GoogleTranslator
|
5 |
|
6 |
+
# Set up Groq API client
|
7 |
+
client = Groq(
|
8 |
+
api_key=os.getenv("GROQ_API_KEY"), # Ensure you add this key to your environment variables
|
9 |
+
)
|
|
|
10 |
|
11 |
def get_highlight_summary(team, player, lang='en'):
|
12 |
+
# Generate the highlight content
|
13 |
highlight = f"Highlight of {player} from {team} in the latest game..."
|
14 |
|
15 |
+
# Call Groq API for chat completions
|
16 |
+
chat_completion = client.chat.completions.create(
|
17 |
+
messages=[
|
18 |
+
{"role": "user", "content": f"Generate a highlight summary for: {highlight}"}
|
19 |
+
],
|
20 |
+
model="llama-3.3-70b-versatile", # Specify the model to use
|
21 |
)
|
22 |
+
|
23 |
+
# Extract the generated summary
|
24 |
+
summary = chat_completion.choices[0].message.content.strip()
|
25 |
|
26 |
# Translate summary if necessary
|
27 |
if lang != 'en':
|