Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import os
|
| 3 |
+
import re
|
| 4 |
+
import json
|
| 5 |
+
from crewai import Agent, Task, Crew, Process
|
| 6 |
+
from langchain_groq import ChatGroq
|
| 7 |
+
from fpdf import FPDF
|
| 8 |
+
from dotenv import load_dotenv
|
| 9 |
+
|
| 10 |
+
# 1. Setup & Helpers
|
| 11 |
+
load_dotenv()
|
| 12 |
+
llm = ChatGroq(temperature=0, model_name="llama3-70b-8192")
|
| 13 |
+
|
| 14 |
+
def extract_json(text):
|
| 15 |
+
match = re.search(r'\{.*\}', text, re.DOTALL)
|
| 16 |
+
if match:
|
| 17 |
+
try:
|
| 18 |
+
return json.loads(match.group(0))
|
| 19 |
+
except:
|
| 20 |
+
return None
|
| 21 |
+
return None
|
| 22 |
+
|
| 23 |
+
def create_pdf(data):
|
| 24 |
+
pdf = FPDF()
|
| 25 |
+
pdf.add_page()
|
| 26 |
+
pdf.set_font("Arial", 'B', 16)
|
| 27 |
+
pdf.cell(0, 10, data.get('match_metadata', {}).get('match_name', 'Report'), ln=1)
|
| 28 |
+
pdf.set_font("Arial", size=12)
|
| 29 |
+
pdf.multi_cell(0, 10, data.get('report_body', 'No content'))
|
| 30 |
+
return pdf.output(dest='S').encode('latin-1')
|
| 31 |
+
|
| 32 |
+
# 2. UI Layout
|
| 33 |
+
st.title("IPL Match Intelligence 🏏")
|
| 34 |
+
url = st.text_input("Enter Ball-by-Ball URL:")
|
| 35 |
+
|
| 36 |
+
if st.button("Analyze Match"):
|
| 37 |
+
# (Agent & Task definitions would be here)
|
| 38 |
+
# ... execution logic ...
|
| 39 |
+
st.write("Processing...")
|