CKT
commited on
Commit
·
c30d3d4
1
Parent(s):
56ef34b
Minor fixes
Browse files
README.md
CHANGED
|
@@ -13,7 +13,7 @@ sdk: gradio
|
|
| 13 |
sdk_version: 5.33.0
|
| 14 |
app_file: app.py
|
| 15 |
pinned: true
|
| 16 |
-
short_description: MCP-native matchmaking to let agents find you dates!
|
| 17 |
---
|
| 18 |
|
| 19 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 13 |
sdk_version: 5.33.0
|
| 14 |
app_file: app.py
|
| 15 |
pinned: true
|
| 16 |
+
short_description: MCP-native matchmaking to let your AI agents find you dates!
|
| 17 |
---
|
| 18 |
|
| 19 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
|
@@ -88,7 +88,7 @@ def save_json_data(filepath, data):
|
|
| 88 |
|
| 89 |
def new_profile(request: gr.Request):
|
| 90 |
"""
|
| 91 |
-
Generates and returns a profile questionnaire, a new public profile_id,
|
| 92 |
and a new private auth_id. Also creates an initial profile stub.
|
| 93 |
"""
|
| 94 |
# 1. Generate profile_id and auth_id
|
|
@@ -272,9 +272,13 @@ def get_matches(request: gr.Request):
|
|
| 272 |
num_matches = min(len(potential_matches_profiles), 3)
|
| 273 |
selected_matches = random.sample(potential_matches_profiles, k=num_matches)
|
| 274 |
|
| 275 |
-
#
|
| 276 |
-
|
| 277 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
|
| 279 |
matches_list = []
|
| 280 |
for match_profile in selected_matches:
|
|
@@ -359,7 +363,12 @@ def get_profile(profile_id_to_get: str, request: gr.Request):
|
|
| 359 |
target_profile.pop("auth_id", None)
|
| 360 |
|
| 361 |
# Construct and add the full image URL, then remove the old filename key
|
| 362 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 363 |
image_filename = target_profile.get("profile_image_filename")
|
| 364 |
image_url = None
|
| 365 |
if image_filename:
|
|
@@ -570,7 +579,13 @@ def upload_profile_picture(image_upload, request: gr.Request):
|
|
| 570 |
if not save_json_data(PROFILES_FILE, profiles):
|
| 571 |
return {"status": "error", "message": "Failed to update profile with new image filename."}
|
| 572 |
|
| 573 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 574 |
|
| 575 |
return {
|
| 576 |
"status": "success",
|
|
@@ -602,8 +617,8 @@ new_profile_demo = gr.Interface(
|
|
| 602 |
fn=new_profile,
|
| 603 |
inputs=None, # No direct input from user for this one, it's triggered by the agent
|
| 604 |
outputs=gr.JSON(label="Questionnaire, IDs, and Instructions"),
|
| 605 |
-
title="Profile Questionnaire",
|
| 606 |
-
description="Generates a new user profile and returns a questionnaire, Profile ID, and Auth ID. (Agent-triggered MCP tool)"
|
| 607 |
)
|
| 608 |
# --- End of New Profile Questionnaire Interface ---
|
| 609 |
|
|
|
|
| 88 |
|
| 89 |
def new_profile(request: gr.Request):
|
| 90 |
"""
|
| 91 |
+
Generates and returns a dating profile questionnaire, a new public profile_id,
|
| 92 |
and a new private auth_id. Also creates an initial profile stub.
|
| 93 |
"""
|
| 94 |
# 1. Generate profile_id and auth_id
|
|
|
|
| 272 |
num_matches = min(len(potential_matches_profiles), 3)
|
| 273 |
selected_matches = random.sample(potential_matches_profiles, k=num_matches)
|
| 274 |
|
| 275 |
+
# Construct base_url with correct protocol
|
| 276 |
+
host = request.headers.get('host', 'localhost:7860')
|
| 277 |
+
if host.startswith('localhost') or host.startswith('127.0.0.1'):
|
| 278 |
+
protocol = 'http'
|
| 279 |
+
else:
|
| 280 |
+
protocol = 'https'
|
| 281 |
+
base_url = f"{protocol}://{host}"
|
| 282 |
|
| 283 |
matches_list = []
|
| 284 |
for match_profile in selected_matches:
|
|
|
|
| 363 |
target_profile.pop("auth_id", None)
|
| 364 |
|
| 365 |
# Construct and add the full image URL, then remove the old filename key
|
| 366 |
+
host = request.headers.get('host', 'localhost:7860')
|
| 367 |
+
if host.startswith('localhost') or host.startswith('127.0.0.1'):
|
| 368 |
+
protocol = 'http'
|
| 369 |
+
else:
|
| 370 |
+
protocol = 'https'
|
| 371 |
+
base_url = f"{protocol}://{host}"
|
| 372 |
image_filename = target_profile.get("profile_image_filename")
|
| 373 |
image_url = None
|
| 374 |
if image_filename:
|
|
|
|
| 579 |
if not save_json_data(PROFILES_FILE, profiles):
|
| 580 |
return {"status": "error", "message": "Failed to update profile with new image filename."}
|
| 581 |
|
| 582 |
+
host = request.headers.get('host', 'localhost:7860')
|
| 583 |
+
if host.startswith('localhost') or host.startswith('127.0.0.1'):
|
| 584 |
+
protocol = 'http'
|
| 585 |
+
else:
|
| 586 |
+
protocol = 'https'
|
| 587 |
+
base_url = f"{protocol}://{host}"
|
| 588 |
+
image_url = f"{base_url}/gradio_api/file=data/profile_images/{new_filename}"
|
| 589 |
|
| 590 |
return {
|
| 591 |
"status": "success",
|
|
|
|
| 617 |
fn=new_profile,
|
| 618 |
inputs=None, # No direct input from user for this one, it's triggered by the agent
|
| 619 |
outputs=gr.JSON(label="Questionnaire, IDs, and Instructions"),
|
| 620 |
+
title="Dating Profile Questionnaire",
|
| 621 |
+
description="Generates a new user dating profile and returns a questionnaire, Profile ID, and Auth ID. (Agent-triggered MCP tool)"
|
| 622 |
)
|
| 623 |
# --- End of New Profile Questionnaire Interface ---
|
| 624 |
|