Spaces:
Build error
Build error
Update mylab/fixed_font_issue.py
Browse files- mylab/fixed_font_issue.py +25 -0
mylab/fixed_font_issue.py
CHANGED
|
@@ -86,6 +86,31 @@ if st.session_state.df is not None and st.session_state.show_preview:
|
|
| 86 |
st.subheader("π Dataset Preview")
|
| 87 |
st.dataframe(st.session_state.df.head())
|
| 88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
# Function to create TXT file
|
| 90 |
def create_text_report_with_viz_temp(report, conclusion, visualizations):
|
| 91 |
content = f"### Analysis Report\n\n{report}\n\n### Visualizations\n"
|
|
|
|
| 86 |
st.subheader("π Dataset Preview")
|
| 87 |
st.dataframe(st.session_state.df.head())
|
| 88 |
|
| 89 |
+
# Ask GPT-4o for Visualization Suggestions
|
| 90 |
+
def ask_gpt4o_for_visualization(query, df, llm):
|
| 91 |
+
columns = ', '.join(df.columns)
|
| 92 |
+
prompt = f"""
|
| 93 |
+
Analyze the query and suggest the best visualization.
|
| 94 |
+
|
| 95 |
+
Query: "{query}"
|
| 96 |
+
Available Columns: {columns}
|
| 97 |
+
|
| 98 |
+
Respond in this JSON format:
|
| 99 |
+
{{
|
| 100 |
+
"chart_type": "bar/box/line/scatter",
|
| 101 |
+
"x_axis": "column_name",
|
| 102 |
+
"y_axis": "column_name",
|
| 103 |
+
"group_by": "optional_column_name"
|
| 104 |
+
}}
|
| 105 |
+
"""
|
| 106 |
+
response = llm.generate(prompt)
|
| 107 |
+
try:
|
| 108 |
+
return json.loads(response)
|
| 109 |
+
except json.JSONDecodeError:
|
| 110 |
+
st.error("β οΈ GPT-4o failed to generate a valid suggestion.")
|
| 111 |
+
return None
|
| 112 |
+
|
| 113 |
+
|
| 114 |
# Function to create TXT file
|
| 115 |
def create_text_report_with_viz_temp(report, conclusion, visualizations):
|
| 116 |
content = f"### Analysis Report\n\n{report}\n\n### Visualizations\n"
|