Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
from transformers import pipeline
|
4 |
+
import os
|
5 |
+
|
6 |
+
# Ensure the file path is correct
|
7 |
+
file_path = 'Archived NFL Futures Odds _SportsOddsHistory.com.csv'
|
8 |
+
|
9 |
+
# Check if file exists
|
10 |
+
if not os.path.exists(file_path):
|
11 |
+
raise FileNotFoundError(f"File not found: {file_path}")
|
12 |
+
|
13 |
+
# Load your data
|
14 |
+
df = pd.read_csv(file_path)
|
15 |
+
|
16 |
+
# Load a pre-trained language model
|
17 |
+
nlp = pipeline("question-answering")
|
18 |
+
|
19 |
+
# Define a function to answer questions
|
20 |
+
def answer_question(question):
|
21 |
+
context = df.to_string()
|
22 |
+
result = nlp(question=question, context=context)
|
23 |
+
return result['answer']
|
24 |
+
|
25 |
+
# Create a Gradio interface
|
26 |
+
iface = gr.Interface(
|
27 |
+
fn=answer_question,
|
28 |
+
inputs="text",
|
29 |
+
outputs="text",
|
30 |
+
title="NFL Futures Odds Analysis Chatbot",
|
31 |
+
description="Ask questions about the archived NFL futures odds."
|
32 |
+
)
|
33 |
+
|
34 |
+
# Launch the interface
|
35 |
+
iface.launch()
|