Spaces:
Paused
Paused
Upload folder using huggingface_hub
Browse files- analysis_template.md +5 -3
- app.py +39 -3
analysis_template.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# UX STRATEGIST TEMPLATE (CLIENT-GRADE)
|
| 2 |
|
| 3 |
You are a Senior UX Strategist and Researcher.
|
|
@@ -13,8 +17,6 @@ You will simulate a persona performing tasks, but the final output must read lik
|
|
| 13 |
|
| 14 |
## 1. Variables
|
| 15 |
|
| 16 |
-
- Persona: {{persona_context}}
|
| 17 |
-
- Tasks: {{tasks_list}}
|
| 18 |
- Target URL: {{url}}
|
| 19 |
- Report ID: {{report_id}}
|
| 20 |
|
|
@@ -24,7 +26,7 @@ You will simulate a persona performing tasks, but the final output must read lik
|
|
| 24 |
|
| 25 |
### Task Execution & Data Collection
|
| 26 |
|
| 27 |
-
1. **Sequential Execution**: Perform the 10 tasks provided in
|
| 28 |
2. **Coordinate Tracking**: For every click or interaction, record the (x, y) coordinates relative to the viewport.
|
| 29 |
3. **Heatmap Generation**: After completing all tasks, generate "Average User Journey Heatmaps" by overlaying the recorded interaction points onto screenshots of the relevant pages.
|
| 30 |
- Save these heatmap images as PNG files in `/user_experience_reports/heatmaps/`.
|
|
|
|
| 1 |
+
# CONTEXT FILE: contexts/context_{{report_id}}.md
|
| 2 |
+
# COMMAND: Use `read_file` or equivalent to read the context file at the path above.
|
| 3 |
+
# It contains the persona JSON and the tasks list for this analysis.
|
| 4 |
+
|
| 5 |
# UX STRATEGIST TEMPLATE (CLIENT-GRADE)
|
| 6 |
|
| 7 |
You are a Senior UX Strategist and Researcher.
|
|
|
|
| 17 |
|
| 18 |
## 1. Variables
|
| 19 |
|
|
|
|
|
|
|
| 20 |
- Target URL: {{url}}
|
| 21 |
- Report ID: {{report_id}}
|
| 22 |
|
|
|
|
| 26 |
|
| 27 |
### Task Execution & Data Collection
|
| 28 |
|
| 29 |
+
1. **Sequential Execution**: Perform the 10 tasks provided in the external context file one by one.
|
| 30 |
2. **Coordinate Tracking**: For every click or interaction, record the (x, y) coordinates relative to the viewport.
|
| 31 |
3. **Heatmap Generation**: After completing all tasks, generate "Average User Journey Heatmaps" by overlaying the recorded interaction points onto screenshots of the relevant pages.
|
| 32 |
- Save these heatmap images as PNG files in `/user_experience_reports/heatmaps/`.
|
app.py
CHANGED
|
@@ -310,6 +310,35 @@ def upload_persona_to_pool(persona_data):
|
|
| 310 |
except Exception as e:
|
| 311 |
print(f"Error uploading persona to pool: {e}")
|
| 312 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
def select_or_create_personas(theme, customer_profile, num_personas, force_method=None, example_file=None):
|
| 314 |
if force_method == "Example Persona" and example_file:
|
| 315 |
add_log(f"Loading example persona from {example_file}...")
|
|
@@ -704,15 +733,22 @@ def start_and_monitor_sessions(personas, tasks, url, session_id):
|
|
| 704 |
|
| 705 |
sessions = []
|
| 706 |
jules_uuids = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 707 |
for persona in personas:
|
| 708 |
# Use provided session_id or append to it if multiple personas?
|
| 709 |
# For simplicity, we use session_id as the report_id too
|
| 710 |
report_id = session_id
|
| 711 |
|
| 712 |
# Format prompt
|
| 713 |
-
prompt = template.replace("{{
|
| 714 |
-
prompt = prompt.replace("{{tasks_list}}", json.dumps(tasks))
|
| 715 |
-
prompt = prompt.replace("{{url}}", url)
|
| 716 |
prompt = prompt.replace("{{report_id}}", report_id)
|
| 717 |
prompt = prompt.replace("{{blablador_api_key}}", BLABLADOR_API_KEY if BLABLADOR_API_KEY else "YOUR_API_KEY")
|
| 718 |
|
|
|
|
| 310 |
except Exception as e:
|
| 311 |
print(f"Error uploading persona to pool: {e}")
|
| 312 |
|
| 313 |
+
def upload_context_to_github(repo_name, session_id, persona, tasks):
|
| 314 |
+
if not gh:
|
| 315 |
+
add_log("ERROR: GitHub client not initialized for context upload.")
|
| 316 |
+
return None
|
| 317 |
+
|
| 318 |
+
file_path = f"contexts/context_{session_id}.md"
|
| 319 |
+
content = f"""# Analysis Context for Session {session_id}
|
| 320 |
+
|
| 321 |
+
## Persona
|
| 322 |
+
{json.dumps(persona, indent=2)}
|
| 323 |
+
|
| 324 |
+
## Tasks
|
| 325 |
+
{json.dumps(tasks, indent=2)}
|
| 326 |
+
"""
|
| 327 |
+
try:
|
| 328 |
+
repo = gh.get_repo(repo_name)
|
| 329 |
+
try:
|
| 330 |
+
# Check if exists (unlikely for new session)
|
| 331 |
+
existing = repo.get_contents(file_path, ref="main")
|
| 332 |
+
repo.update_file(file_path, f"Update context for {session_id}", content, existing.sha, branch="main")
|
| 333 |
+
except:
|
| 334 |
+
repo.create_file(file_path, f"Add context for {session_id}", content, branch="main")
|
| 335 |
+
|
| 336 |
+
add_log(f"Successfully uploaded context file to {repo_name} main branch.")
|
| 337 |
+
return f"https://github.com/{repo_name}/blob/main/{file_path}"
|
| 338 |
+
except Exception as e:
|
| 339 |
+
add_log(f"ERROR uploading context to GitHub: {e}")
|
| 340 |
+
return None
|
| 341 |
+
|
| 342 |
def select_or_create_personas(theme, customer_profile, num_personas, force_method=None, example_file=None):
|
| 343 |
if force_method == "Example Persona" and example_file:
|
| 344 |
add_log(f"Loading example persona from {example_file}...")
|
|
|
|
| 733 |
|
| 734 |
sessions = []
|
| 735 |
jules_uuids = []
|
| 736 |
+
|
| 737 |
+
# Upload context file to main branch
|
| 738 |
+
context_url = upload_context_to_github(repo_name, session_id, personas[0], tasks)
|
| 739 |
+
if not context_url:
|
| 740 |
+
add_log("Warning: Failed to upload context file. Jules might not find it.")
|
| 741 |
+
else:
|
| 742 |
+
add_log(f"Waiting 5 seconds for GitHub propagation...")
|
| 743 |
+
time.sleep(5)
|
| 744 |
+
|
| 745 |
for persona in personas:
|
| 746 |
# Use provided session_id or append to it if multiple personas?
|
| 747 |
# For simplicity, we use session_id as the report_id too
|
| 748 |
report_id = session_id
|
| 749 |
|
| 750 |
# Format prompt
|
| 751 |
+
prompt = template.replace("{{url}}", url)
|
|
|
|
|
|
|
| 752 |
prompt = prompt.replace("{{report_id}}", report_id)
|
| 753 |
prompt = prompt.replace("{{blablador_api_key}}", BLABLADOR_API_KEY if BLABLADOR_API_KEY else "YOUR_API_KEY")
|
| 754 |
|