style: chart size in gradio UI
Browse files
app.py
CHANGED
|
@@ -29,10 +29,10 @@ def load_db_configs():
|
|
| 29 |
return configs["db_configs"]
|
| 30 |
|
| 31 |
|
| 32 |
-
def
|
| 33 |
with open(image_path, "rb") as f:
|
| 34 |
encoded = base64.b64encode(f.read()).decode("utf-8")
|
| 35 |
-
return f"
|
| 36 |
|
| 37 |
|
| 38 |
# ====================================== Async-compatible wrapper
|
|
@@ -56,7 +56,7 @@ async def run_agent(request, history=None):
|
|
| 56 |
if generated_files:
|
| 57 |
image_path = os.path.join(PANDAS_EXPORTS_PATH, generated_files[0])
|
| 58 |
try:
|
| 59 |
-
image_markdown =
|
| 60 |
output = f"{image_markdown}\n\n{response}"
|
| 61 |
os.remove(image_path) # Clean up the image file
|
| 62 |
except Exception as e:
|
|
|
|
| 29 |
return configs["db_configs"]
|
| 30 |
|
| 31 |
|
| 32 |
+
def image_to_base64_html(image_path, alt_text="Customer Status", width=600):
|
| 33 |
with open(image_path, "rb") as f:
|
| 34 |
encoded = base64.b64encode(f.read()).decode("utf-8")
|
| 35 |
+
return f'<img src="data:image/png;base64,{encoded}" alt="{alt_text}" style="width:{width}px; max-width:100%; display:block; margin:0 auto 24px auto; border-radius:12px; box-shadow:0 2px 12px rgba(0,0,0,0.08);" />'
|
| 36 |
|
| 37 |
|
| 38 |
# ====================================== Async-compatible wrapper
|
|
|
|
| 56 |
if generated_files:
|
| 57 |
image_path = os.path.join(PANDAS_EXPORTS_PATH, generated_files[0])
|
| 58 |
try:
|
| 59 |
+
image_markdown = image_to_base64_html(image_path)
|
| 60 |
output = f"{image_markdown}\n\n{response}"
|
| 61 |
os.remove(image_path) # Clean up the image file
|
| 62 |
except Exception as e:
|