Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,7 @@ from tools.final_answer import FinalAnswerTool
|
|
| 7 |
from Gradio_UI import GradioUI
|
| 8 |
|
| 9 |
import os
|
|
|
|
| 10 |
import qrcode
|
| 11 |
from smolagents.agent_types import AgentImage
|
| 12 |
|
|
@@ -25,12 +26,7 @@ def generate_qr_code(text:str)-> AgentImage: #it's import to specify the return
|
|
| 25 |
qr.make(fit=True)
|
| 26 |
img = qr.make_image(fill_color="black", back_color="white").convert('RGB')
|
| 27 |
print(img.size)
|
| 28 |
-
|
| 29 |
-
save_path = os.path.abspath(filename)
|
| 30 |
-
img.save(save_path)
|
| 31 |
-
print(f"DEBUG: Saved absolute path to: {save_path}")
|
| 32 |
-
return AgentImage(save_path)
|
| 33 |
-
# return AgentImage(img)
|
| 34 |
except Exception as e:
|
| 35 |
return f"Error generating QR code:{str(e)}"
|
| 36 |
# return "What magic will you build ?"
|
|
@@ -82,7 +78,8 @@ agent = CodeAgent(
|
|
| 82 |
prompt_templates=prompt_templates
|
| 83 |
)
|
| 84 |
|
| 85 |
-
|
| 86 |
-
|
|
|
|
| 87 |
|
| 88 |
-
GradioUI(agent).launch(allowed_paths=[current_dir])
|
|
|
|
| 7 |
from Gradio_UI import GradioUI
|
| 8 |
|
| 9 |
import os
|
| 10 |
+
import tempfile
|
| 11 |
import qrcode
|
| 12 |
from smolagents.agent_types import AgentImage
|
| 13 |
|
|
|
|
| 26 |
qr.make(fit=True)
|
| 27 |
img = qr.make_image(fill_color="black", back_color="white").convert('RGB')
|
| 28 |
print(img.size)
|
| 29 |
+
return AgentImage(img)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
except Exception as e:
|
| 31 |
return f"Error generating QR code:{str(e)}"
|
| 32 |
# return "What magic will you build ?"
|
|
|
|
| 78 |
prompt_templates=prompt_templates
|
| 79 |
)
|
| 80 |
|
| 81 |
+
temp_dir = tempfile.gettempdir()
|
| 82 |
+
current_dir = os.getcwd()
|
| 83 |
+
print(f"Adding allowed paths: {current_dir} and {temp_dir}")
|
| 84 |
|
| 85 |
+
GradioUI(agent).launch(allowed_paths=[current_dir, temp_dir])
|