Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -120,13 +120,12 @@ def analyze_data(data, visualization_type, class_size=10):
|
|
| 120 |
|
| 121 |
# Function to generate a prompt based on the data analysis
|
| 122 |
def generate_groq_prompt(data, visualization_type, class_size):
|
| 123 |
-
# Convert
|
| 124 |
-
|
| 125 |
-
data_without_index = sample_data.to_string(index=False)
|
| 126 |
|
| 127 |
prompt = f"""
|
| 128 |
-
Here is
|
| 129 |
-
{
|
| 130 |
|
| 131 |
The user has selected the '{visualization_type}' visualization type with a class size of {class_size}.
|
| 132 |
Please generate Python code that does this and for any data, please don't use any file input. Write the data in the code.
|
|
@@ -157,13 +156,11 @@ if uploaded_file is not None:
|
|
| 157 |
# User input for class size customization
|
| 158 |
class_size = st.slider("Select the class size for certain plots (e.g., Histogram)", 5, 50, 10)
|
| 159 |
|
| 160 |
-
# Perform Analysis and Visualization
|
| 161 |
prompt = analyze_data(data, visualization_type, class_size)
|
| 162 |
|
| 163 |
-
# Display prompt
|
| 164 |
st.subheader("Prompt Sent to Groq")
|
| 165 |
-
st.
|
| 166 |
-
|
| 167 |
# Chat with Groq Section
|
| 168 |
st.subheader("Chat with Groq")
|
| 169 |
chat_input = st.text_area("Ask Groq questions about the data:")
|
|
|
|
| 120 |
|
| 121 |
# Function to generate a prompt based on the data analysis
|
| 122 |
def generate_groq_prompt(data, visualization_type, class_size):
|
| 123 |
+
# Convert DataFrame to a CSV-like string for readability
|
| 124 |
+
data_snippet = data.head(10).to_csv(index=False) # Limit to the first 10 rows
|
|
|
|
| 125 |
|
| 126 |
prompt = f"""
|
| 127 |
+
Here is a preview of the dataset (in CSV format):
|
| 128 |
+
{data_snippet}
|
| 129 |
|
| 130 |
The user has selected the '{visualization_type}' visualization type with a class size of {class_size}.
|
| 131 |
Please generate Python code that does this and for any data, please don't use any file input. Write the data in the code.
|
|
|
|
| 156 |
# User input for class size customization
|
| 157 |
class_size = st.slider("Select the class size for certain plots (e.g., Histogram)", 5, 50, 10)
|
| 158 |
|
|
|
|
| 159 |
prompt = analyze_data(data, visualization_type, class_size)
|
| 160 |
|
| 161 |
+
# Display the prompt that will be sent to Groq
|
| 162 |
st.subheader("Prompt Sent to Groq")
|
| 163 |
+
st.code(prompt, language="plaintext")
|
|
|
|
| 164 |
# Chat with Groq Section
|
| 165 |
st.subheader("Chat with Groq")
|
| 166 |
chat_input = st.text_area("Ask Groq questions about the data:")
|