Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ import tempfile
|
|
7 |
import subprocess
|
8 |
from groq import Groq
|
9 |
|
10 |
-
# Groq API Key setup
|
11 |
GROQ_API_KEY = "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"
|
12 |
client = Groq(api_key=GROQ_API_KEY)
|
13 |
|
@@ -79,10 +79,6 @@ def analyze_data(data, visualization_type):
|
|
79 |
ax.set_xlabel(x_col)
|
80 |
ax.set_ylabel(y_col)
|
81 |
st.pyplot(fig)
|
82 |
-
# Visualization logic
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
|
87 |
elif visualization_type == "Line Graph" and not numeric_data.empty:
|
88 |
st.subheader("Line Graph")
|
@@ -95,9 +91,6 @@ def analyze_data(data, visualization_type):
|
|
95 |
ax.set_ylabel(y_col)
|
96 |
st.pyplot(fig)
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
elif visualization_type == "Area Chart" and not numeric_data.empty:
|
102 |
st.subheader("Area Chart")
|
103 |
column = st.selectbox("Select a column for the Area Chart:", numeric_data.columns)
|
@@ -123,7 +116,7 @@ def generate_groq_prompt(data, visualization_type):
|
|
123 |
Here is the summary statistics for the dataset:
|
124 |
{data_without_index}
|
125 |
|
126 |
-
The user has selected the '{visualization_type}' visualization type
|
127 |
Please generate Python code that does this and for any data, please don't use any file input. Write the data in the code.
|
128 |
"""
|
129 |
|
@@ -141,20 +134,20 @@ if uploaded_file is not None:
|
|
141 |
if data is not None:
|
142 |
data = preprocess_dataframe(data) # Fix serialization issues
|
143 |
st.subheader("Uploaded Data")
|
144 |
-
st.write(data
|
145 |
|
146 |
# Visualization Selection
|
147 |
visualization_type = st.selectbox(
|
148 |
"Select a visualization type:",
|
149 |
-
[
|
150 |
)
|
151 |
|
152 |
-
# User input for class size customization
|
153 |
-
|
154 |
-
|
155 |
# Perform Analysis and Visualization
|
156 |
prompt = analyze_data(data, visualization_type)
|
157 |
|
|
|
|
|
|
|
158 |
|
159 |
# Chat with Groq Section
|
160 |
st.subheader("Chat with Groq")
|
@@ -182,3 +175,4 @@ if uploaded_file is not None:
|
|
182 |
|
183 |
|
184 |
|
|
|
|
7 |
import subprocess
|
8 |
from groq import Groq
|
9 |
|
10 |
+
# Groq API Key setup
|
11 |
GROQ_API_KEY = "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"
|
12 |
client = Groq(api_key=GROQ_API_KEY)
|
13 |
|
|
|
79 |
ax.set_xlabel(x_col)
|
80 |
ax.set_ylabel(y_col)
|
81 |
st.pyplot(fig)
|
|
|
|
|
|
|
|
|
82 |
|
83 |
elif visualization_type == "Line Graph" and not numeric_data.empty:
|
84 |
st.subheader("Line Graph")
|
|
|
91 |
ax.set_ylabel(y_col)
|
92 |
st.pyplot(fig)
|
93 |
|
|
|
|
|
|
|
94 |
elif visualization_type == "Area Chart" and not numeric_data.empty:
|
95 |
st.subheader("Area Chart")
|
96 |
column = st.selectbox("Select a column for the Area Chart:", numeric_data.columns)
|
|
|
116 |
Here is the summary statistics for the dataset:
|
117 |
{data_without_index}
|
118 |
|
119 |
+
The user has selected the '{visualization_type}' visualization type.
|
120 |
Please generate Python code that does this and for any data, please don't use any file input. Write the data in the code.
|
121 |
"""
|
122 |
|
|
|
134 |
if data is not None:
|
135 |
data = preprocess_dataframe(data) # Fix serialization issues
|
136 |
st.subheader("Uploaded Data")
|
137 |
+
st.write(data) # Display the full dataset without truncation
|
138 |
|
139 |
# Visualization Selection
|
140 |
visualization_type = st.selectbox(
|
141 |
"Select a visualization type:",
|
142 |
+
["Bar Chart", "Line Graph", "Area Chart"]
|
143 |
)
|
144 |
|
|
|
|
|
|
|
145 |
# Perform Analysis and Visualization
|
146 |
prompt = analyze_data(data, visualization_type)
|
147 |
|
148 |
+
# Show the prompt sent to Groq
|
149 |
+
st.subheader("Prompt Sent to Groq")
|
150 |
+
st.text(prompt)
|
151 |
|
152 |
# Chat with Groq Section
|
153 |
st.subheader("Chat with Groq")
|
|
|
175 |
|
176 |
|
177 |
|
178 |
+
|