Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,21 @@
|
|
| 1 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
def format_analysis_report(raw_output, visuals):
|
| 4 |
try:
|
| 5 |
# Check if raw_output is already a dictionary
|
|
@@ -27,4 +43,12 @@ def format_analysis_report(raw_output, visuals):
|
|
| 27 |
return report, visuals
|
| 28 |
except Exception as e:
|
| 29 |
print(f"Error formatting report: {e}")
|
| 30 |
-
return raw_output, visuals
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from smolagents import HfApiModel, CodeAgent
|
| 3 |
+
from huggingface_hub import login
|
| 4 |
+
import os
|
| 5 |
+
import shutil
|
| 6 |
+
import ast # Add missing import
|
| 7 |
|
| 8 |
+
# Add this before model initialization
|
| 9 |
+
hf_token = os.getenv("HF_TOKEN")
|
| 10 |
+
login(token=hf_token, add_to_git_credential=True)
|
| 11 |
+
|
| 12 |
+
# Then create model with explicit token
|
| 13 |
+
model = HfApiModel(
|
| 14 |
+
"mistralai/Mixtral-8x7B-Instruct-v0.1",
|
| 15 |
+
token=hf_token # Pass token explicitly
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
# Add this formatting function
|
| 19 |
def format_analysis_report(raw_output, visuals):
|
| 20 |
try:
|
| 21 |
# Check if raw_output is already a dictionary
|
|
|
|
| 43 |
return report, visuals
|
| 44 |
except Exception as e:
|
| 45 |
print(f"Error formatting report: {e}")
|
| 46 |
+
return raw_output, visuals
|
| 47 |
+
|
| 48 |
+
def format_observations(observations):
|
| 49 |
+
items = []
|
| 50 |
+
for key, value in observations.items():
|
| 51 |
+
if 'proportions' in key:
|
| 52 |
+
items.append(f"""
|
| 53 |
+
<div style="margin: 15px 0; padding: 15px; background: white; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.05);">
|
| 54 |
+
<h3 style="margin: 0 0 10px 0; color: #4A708
|