Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -36,16 +36,13 @@ class AIShoppingAnalyzer:
|
|
36 |
|
37 |
return MultimodalWebSurfer(
|
38 |
name="websurfer_agent",
|
39 |
-
description=description,
|
40 |
model_client=self.model_client,
|
|
|
41 |
headless=True,
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
"--disable-setuid-sandbox"
|
47 |
-
]
|
48 |
-
}
|
49 |
)
|
50 |
|
51 |
def create_assistant(self) -> AssistantAgent:
|
@@ -122,6 +119,7 @@ class AIShoppingAnalyzer:
|
|
122 |
"""Run the analysis with proper cleanup"""
|
123 |
websurfer = None
|
124 |
try:
|
|
|
125 |
query = (
|
126 |
f"Analyze the e-commerce experience for {website_url} focusing on:\n"
|
127 |
f"1. Product findability in the {product_category} category\n"
|
@@ -133,6 +131,7 @@ class AIShoppingAnalyzer:
|
|
133 |
if specific_product:
|
134 |
query += f"\n5. Detailed analysis of this specific product: {specific_product}"
|
135 |
|
|
|
136 |
websurfer = self.create_websurfer()
|
137 |
assistant = self.create_assistant()
|
138 |
team = self.create_team(websurfer, assistant)
|
@@ -153,9 +152,12 @@ class AIShoppingAnalyzer:
|
|
153 |
finally:
|
154 |
if websurfer:
|
155 |
try:
|
|
|
156 |
await websurfer.close()
|
|
|
157 |
except Exception as e:
|
158 |
-
print(f"
|
|
|
159 |
|
160 |
def create_gradio_interface() -> gr.Blocks:
|
161 |
"""Create the Gradio interface for the AI Shopping Analyzer"""
|
@@ -342,7 +344,7 @@ def create_gradio_interface() -> gr.Blocks:
|
|
342 |
analyze_button = gr.Button(
|
343 |
"Analyze Site",
|
344 |
size="lg",
|
345 |
-
variant="
|
346 |
)
|
347 |
|
348 |
# Right column for output
|
|
|
36 |
|
37 |
return MultimodalWebSurfer(
|
38 |
name="websurfer_agent",
|
|
|
39 |
model_client=self.model_client,
|
40 |
+
description=description,
|
41 |
headless=True,
|
42 |
+
to_save_screenshots=True, # Save screenshots for analysis
|
43 |
+
use_ocr=True, # Enable OCR for better text extraction
|
44 |
+
to_resize_viewport=True, # Ensure proper viewport sizing
|
45 |
+
debug_dir="debug_logs" # Save debug information
|
|
|
|
|
|
|
46 |
)
|
47 |
|
48 |
def create_assistant(self) -> AssistantAgent:
|
|
|
119 |
"""Run the analysis with proper cleanup"""
|
120 |
websurfer = None
|
121 |
try:
|
122 |
+
# Set up the analysis query
|
123 |
query = (
|
124 |
f"Analyze the e-commerce experience for {website_url} focusing on:\n"
|
125 |
f"1. Product findability in the {product_category} category\n"
|
|
|
131 |
if specific_product:
|
132 |
query += f"\n5. Detailed analysis of this specific product: {specific_product}"
|
133 |
|
134 |
+
# Initialize agents with proper configuration
|
135 |
websurfer = self.create_websurfer()
|
136 |
assistant = self.create_assistant()
|
137 |
team = self.create_team(websurfer, assistant)
|
|
|
152 |
finally:
|
153 |
if websurfer:
|
154 |
try:
|
155 |
+
# Properly close the browser
|
156 |
await websurfer.close()
|
157 |
+
print("Browser closed successfully")
|
158 |
except Exception as e:
|
159 |
+
print(f"Error closing browser: {str(e)}")
|
160 |
+
|
161 |
|
162 |
def create_gradio_interface() -> gr.Blocks:
|
163 |
"""Create the Gradio interface for the AI Shopping Analyzer"""
|
|
|
344 |
analyze_button = gr.Button(
|
345 |
"Analyze Site",
|
346 |
size="lg",
|
347 |
+
variant="secondary"
|
348 |
)
|
349 |
|
350 |
# Right column for output
|