Update app.py
Browse files
app.py
CHANGED
@@ -35,7 +35,8 @@ def process_file(api_key, file, instructions):
|
|
35 |
buf = io.BytesIO()
|
36 |
plt.savefig(buf, format='png')
|
37 |
buf.seek(0)
|
38 |
-
|
|
|
39 |
plt.close()
|
40 |
|
41 |
return visualizations
|
@@ -43,7 +44,7 @@ def process_file(api_key, file, instructions):
|
|
43 |
# Gradio interface
|
44 |
with gr.Blocks() as demo:
|
45 |
gr.Markdown("Data Visualization with Gemini")
|
46 |
-
api_key = gr.Textbox(label="Enter Gemini API Key")
|
47 |
file = gr.File(label="Upload Excel or CSV file")
|
48 |
instructions = gr.Textbox(label="Optional visualization instructions")
|
49 |
submit = gr.Button("Generate Visualizations")
|
|
|
35 |
buf = io.BytesIO()
|
36 |
plt.savefig(buf, format='png')
|
37 |
buf.seek(0)
|
38 |
+
img_str = base64.b64encode(buf.getvalue()).decode()
|
39 |
+
visualizations.append(f"data:image/png;base64,{img_str}")
|
40 |
plt.close()
|
41 |
|
42 |
return visualizations
|
|
|
44 |
# Gradio interface
|
45 |
with gr.Blocks() as demo:
|
46 |
gr.Markdown("Data Visualization with Gemini")
|
47 |
+
api_key = gr.Textbox(label="Enter Gemini API Key", type="password")
|
48 |
file = gr.File(label="Upload Excel or CSV file")
|
49 |
instructions = gr.Textbox(label="Optional visualization instructions")
|
50 |
submit = gr.Button("Generate Visualizations")
|