CKT commited on
Commit
3f6f4f8
·
1 Parent(s): 9bfdb4b

e2e tested

Browse files
Files changed (3) hide show
  1. app.py +19 -19
  2. data/messages.json +32 -0
  3. data/profiles.json +44 -0
app.py CHANGED
@@ -100,8 +100,8 @@ def profile_questionnaire(request: gr.Request):
100
  # Decide how to handle this error - maybe return an error to the client?
101
 
102
  # 4. Return IDs, questionnaire data, and instructions
103
- instructions_for_agent = "You have received a `profile_id` (public identifier for this user\'s profile) and an `auth_id` (private key for authentication for this user). Please ask the user to store both securely. The `auth_id` must be sent as an `X-Auth-ID` header in subsequent requests that require authentication for this user (e.g., `update_profile_answers`, `get_matches`, `get_messages`, `get_profile` for own profile, `send_message`). The `profile_id` is used to publicly identify this user to others (e.g., in matches, or when sending/receiving messages)."
104
- instructions_for_user = "Your profile creation process has started! You\'ve been assigned a unique Profile ID and a secret Auth ID. Your AI agent will use these to manage your profile and interactions."
105
 
106
  return {
107
  "profile_id": profile_id,
@@ -200,30 +200,30 @@ def get_matches(request: gr.Request):
200
  if not requester_profile_id:
201
  return {"status": "error", "message": "Authentication failed: Invalid X-Auth-ID."}
202
 
203
- all_profile_ids = list(profiles.keys())
204
- # Exclude the user's own profile from potential matches
205
- potential_matches_ids = [pid for pid in all_profile_ids if pid != requester_profile_id]
 
 
206
 
207
- # Randomly select up to 3 matches
208
- num_matches = min(len(potential_matches_ids), 3)
209
- selected_match_ids = random.sample(potential_matches_ids, k=num_matches)
210
 
211
  matches_list = []
212
- for match_id in selected_match_ids:
213
- match_profile = profiles.get(match_id)
214
- if match_profile:
215
- matches_list.append({
216
- "profile_id": match_profile.get("profile_id"),
217
- "name": match_profile.get("name"),
218
- "profile_summary": match_profile.get("profile_summary"),
219
- "profile_image_filename": match_profile.get("profile_image_filename")
220
- })
221
 
222
  return {
223
  "status": "success",
224
  "matches": matches_list,
225
- "instructions_for_agent": "You have received a list of matches. For each match, you can call `get_profile` using their `profile_id` to get more details (this may have a cost). You can also use `send_message` to send a message to a match's `profile_id`.",
226
- "instructions_for_user": "Here are some potential matches! Your AI agent can get more details on them or help you send a message."
227
  }
228
 
229
  def get_profile(profile_id_to_get: str, request: gr.Request):
 
100
  # Decide how to handle this error - maybe return an error to the client?
101
 
102
  # 4. Return IDs, questionnaire data, and instructions
103
+ instructions_for_agent = "You have received a `profile_id` (public identifier for this user\'s profile) and an `auth_id` (private key for authentication for this user). Please ask the user to store both securely. The `auth_id` must be sent as an `X-Auth-ID` header in subsequent requests that require authentication for this user (e.g., `update_profile_answers`, `get_matches`, `get_messages`, `get_profile` for own profile, `send_message`). The `profile_id` is used to publicly identify this user to others (e.g., in matches, or when sending/receiving messages). You must now walk the user through the questionnaire, preferably question by question, and collect the answers (in preparation to update the user's profile using update_profile_answers)."
104
+ instructions_for_user = "Your profile creation process has started! You\'ve been assigned a unique Profile ID and a secret Auth ID. Your AI agent will use these to manage your profile and interactions. You must now walk through the questionnaire, preferably question by question, and provide your answers."
105
 
106
  return {
107
  "profile_id": profile_id,
 
200
  if not requester_profile_id:
201
  return {"status": "error", "message": "Authentication failed: Invalid X-Auth-ID."}
202
 
203
+ # Filter for potential matches: not the user themselves, and have a non-blank name.
204
+ potential_matches_profiles = [
205
+ profile for pid, profile in profiles.items()
206
+ if pid != requester_profile_id and profile.get("name")
207
+ ]
208
 
209
+ # Randomly select up to 3 matches from the filtered list
210
+ num_matches = min(len(potential_matches_profiles), 3)
211
+ selected_matches = random.sample(potential_matches_profiles, k=num_matches)
212
 
213
  matches_list = []
214
+ for match_profile in selected_matches:
215
+ matches_list.append({
216
+ "profile_id": match_profile.get("profile_id"),
217
+ "name": match_profile.get("name"),
218
+ "profile_summary": match_profile.get("profile_summary"),
219
+ "profile_image_filename": match_profile.get("profile_image_filename")
220
+ })
 
 
221
 
222
  return {
223
  "status": "success",
224
  "matches": matches_list,
225
+ "instructions_for_agent": "You have received a list of matches. For each match, you can call `get_profile` using their `profile_id` to get more details. You can also use `send_message` to send a message to a match's `profile_id`.",
226
+ "instructions_for_user": "Here are some potential matches! Your AI agent can get more details on them ($0.10 per profile) or help you send a message ($1.00 per message). Or, if you don't like any of your matches, you can call `get_matches` again to get a new list."
227
  }
228
 
229
  def get_profile(profile_id_to_get: str, request: gr.Request):
data/messages.json CHANGED
@@ -23,5 +23,37 @@
23
  "timestamp": "2025-06-06T06:44:02.018941+00:00",
24
  "read_status": true,
25
  "payment_confirmation_id": "not_provided"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  }
27
  ]
 
23
  "timestamp": "2025-06-06T06:44:02.018941+00:00",
24
  "read_status": true,
25
  "payment_confirmation_id": "not_provided"
26
+ },
27
+ {
28
+ "message_id": "e5cb586f-f664-40d5-812b-527a700477f0",
29
+ "sender_profile_id": "user_y38k71ox",
30
+ "receiver_profile_id": "user_t2ysgmnp",
31
+ "content": "Hey Charlie",
32
+ "timestamp": "2025-06-06T07:10:46.319365+00:00",
33
+ "read_status": true
34
+ },
35
+ {
36
+ "message_id": "d4cda280-99bc-4960-9419-0daf71c48c78",
37
+ "sender_profile_id": "user_y38k71ox",
38
+ "receiver_profile_id": "user_t2ysgmnp",
39
+ "content": "Hey Charlie",
40
+ "timestamp": "2025-06-06T07:13:28.067145+00:00",
41
+ "read_status": true
42
+ },
43
+ {
44
+ "message_id": "f5ae4191-ddc9-430d-a5a9-0498e3dee627",
45
+ "sender_profile_id": "user_y38k71ox",
46
+ "receiver_profile_id": "user_t2ysgmnp",
47
+ "content": "Hey Charlie",
48
+ "timestamp": "2025-06-06T07:16:10.584026+00:00",
49
+ "read_status": true
50
+ },
51
+ {
52
+ "message_id": "3d565b74-a0b2-4006-b501-b83637a180f4",
53
+ "sender_profile_id": "user_1p6vx64b",
54
+ "receiver_profile_id": "user_t2ysgmnp",
55
+ "content": "Hey Charlie",
56
+ "timestamp": "2025-06-06T07:18:28.078347+00:00",
57
+ "read_status": true
58
  }
59
  ]
data/profiles.json CHANGED
@@ -64,5 +64,49 @@
64
  "q_looking_for": "A partner-in-crime for game nights and tech talks.",
65
  "q_vibe": "Geeky and friendly."
66
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  }
68
  }
 
64
  "q_looking_for": "A partner-in-crime for game nights and tech talks.",
65
  "q_vibe": "Geeky and friendly."
66
  }
67
+ },
68
+ "user_gq61ow1v": {
69
+ "profile_id": "user_gq61ow1v",
70
+ "auth_id": "2e30881b-4dbb-46cf-a35a-c08e408e1c26",
71
+ "created_at": "2025-06-06T06:56:50.622902+00:00",
72
+ "updated_at": "2025-06-06T06:56:50.622902+00:00",
73
+ "name": "",
74
+ "profile_image_filename": null,
75
+ "profile_summary": "",
76
+ "answers": {}
77
+ },
78
+ "user_1p6vx64b": {
79
+ "profile_id": "user_1p6vx64b",
80
+ "auth_id": "1a824149-5ddc-4489-8856-0c774042b538",
81
+ "created_at": "2025-06-06T07:00:38.209630+00:00",
82
+ "updated_at": "2025-06-06T07:04:31.734665+00:00",
83
+ "name": "Chris",
84
+ "profile_image_filename": "placeholder.png",
85
+ "profile_summary": "I am a fun guy.",
86
+ "answers": {
87
+ "q_hobby": "I like to play video games.",
88
+ "q_looking_for": "Someone to play video games with.",
89
+ "q_vibe": "Homebody."
90
+ }
91
+ },
92
+ "user_fx0tg6yb": {
93
+ "profile_id": "user_fx0tg6yb",
94
+ "auth_id": "19d5a977-7402-43ff-99a2-23f7e091bc79",
95
+ "created_at": "2025-06-06T07:30:26.098125+00:00",
96
+ "updated_at": "2025-06-06T07:30:26.098125+00:00",
97
+ "name": "",
98
+ "profile_image_filename": null,
99
+ "profile_summary": "",
100
+ "answers": {}
101
+ },
102
+ "user_u1d6b1mw": {
103
+ "profile_id": "user_u1d6b1mw",
104
+ "auth_id": "1a4033ff-d4a6-436f-883b-a81bc48caabb",
105
+ "created_at": "2025-06-06T07:30:39.861151+00:00",
106
+ "updated_at": "2025-06-06T07:30:39.861151+00:00",
107
+ "name": "",
108
+ "profile_image_filename": null,
109
+ "profile_summary": "",
110
+ "answers": {}
111
  }
112
  }