Spaces:
Runtime error
Runtime error
Ari
commited on
Commit
·
d2e64c6
1
Parent(s):
74803e8
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import openai
|
| 3 |
import pandas as pd
|
| 4 |
-
import matplotlib.pyplot as plt
|
| 5 |
-
import seaborn as sns
|
| 6 |
|
| 7 |
# Load your CSV file
|
| 8 |
data = pd.read_csv("RR.csv")
|
|
@@ -31,52 +29,25 @@ def get_insights(question):
|
|
| 31 |
answer = query_gpt(prompt)
|
| 32 |
return answer
|
| 33 |
|
| 34 |
-
def create_visualization_report():
|
| 35 |
-
# Customize your visualizations, for example:
|
| 36 |
-
# Plotting a heatmap to show correlations between columns
|
| 37 |
-
fig, ax = plt.subplots(figsize=(10, 8))
|
| 38 |
-
sns.heatmap(data.corr(), annot=True, fmt=".2f", cmap="coolwarm", ax=ax)
|
| 39 |
-
plt.title("Correlation Heatmap")
|
| 40 |
-
|
| 41 |
-
# Save the visualization to a file
|
| 42 |
-
fig.savefig("visualization_report.png")
|
| 43 |
-
plt.close(fig)
|
| 44 |
-
|
| 45 |
-
# Return the saved file
|
| 46 |
-
return "visualization_report.png"
|
| 47 |
-
|
| 48 |
markdown_data = f"Mock Dataset For GDS Social MBR :\n```\n{data.head(10).to_string(index=False)}\n```\n"
|
| 49 |
|
| 50 |
-
def gradio_wrapper(question, generate_visualization):
|
| 51 |
-
if generate_visualization:
|
| 52 |
-
return create_visualization_report()
|
| 53 |
-
else:
|
| 54 |
-
return get_insights(question)
|
| 55 |
-
|
| 56 |
iface = gr.Interface(
|
| 57 |
-
fn=
|
| 58 |
inputs=[
|
| 59 |
gr.inputs.Textbox(lines=2, label="Enter your question"),
|
| 60 |
-
gr.inputs.Checkbox(label="Generate Visualization Report"),
|
| 61 |
],
|
| 62 |
-
outputs=
|
| 63 |
-
|
| 64 |
-
gr.outputs.Image(type="filepath", label="Visualization Report"),
|
| 65 |
-
],
|
| 66 |
-
title="GPT-powered Q&A with Visualization",
|
| 67 |
description=markdown_data,
|
| 68 |
examples=[
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
],
|
| 75 |
-
|
| 76 |
allow_screenshot=False,
|
| 77 |
theme="compact",
|
| 78 |
layout="vertical",
|
| 79 |
)
|
| 80 |
|
| 81 |
iface.launch(inbrowser=True)
|
| 82 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import openai
|
| 3 |
import pandas as pd
|
|
|
|
|
|
|
| 4 |
|
| 5 |
# Load your CSV file
|
| 6 |
data = pd.read_csv("RR.csv")
|
|
|
|
| 29 |
answer = query_gpt(prompt)
|
| 30 |
return answer
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
markdown_data = f"Mock Dataset For GDS Social MBR :\n```\n{data.head(10).to_string(index=False)}\n```\n"
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
iface = gr.Interface(
|
| 35 |
+
fn=get_insights,
|
| 36 |
inputs=[
|
| 37 |
gr.inputs.Textbox(lines=2, label="Enter your question"),
|
|
|
|
| 38 |
],
|
| 39 |
+
outputs="text",
|
| 40 |
+
title="GPT-powered Q&A",
|
|
|
|
|
|
|
|
|
|
| 41 |
description=markdown_data,
|
| 42 |
examples=[
|
| 43 |
+
("Are there any trends in sales forecast or actual sales?",),
|
| 44 |
+
("How does the marketing budget correlate with the sales actual?",),
|
| 45 |
+
("Can you identify any months with a significantly higher or lower number of support chats or calls compared to the overall average?",),
|
| 46 |
+
("Are there any patterns that suggest a need for additional staff during specific periods based on support chats and calls?",),
|
| 47 |
+
],
|
|
|
|
|
|
|
| 48 |
allow_screenshot=False,
|
| 49 |
theme="compact",
|
| 50 |
layout="vertical",
|
| 51 |
)
|
| 52 |
|
| 53 |
iface.launch(inbrowser=True)
|
|
|