(conv_idx, locomo_df, frame, version, top_k=20, num_workers=1)
| 234 | |
| 235 | |
| 236 | def process_user(conv_idx, locomo_df, frame, version, top_k=20, num_workers=1): |
| 237 | search_results = defaultdict(list) |
| 238 | qa_set = locomo_df["qa"].iloc[conv_idx] |
| 239 | conversation = locomo_df["conversation"].iloc[conv_idx] |
| 240 | speaker_a = conversation.get("speaker_a") |
| 241 | speaker_b = conversation.get("speaker_b") |
| 242 | speaker_a_user_id = f"locomo_exp_user_{conv_idx}_speaker_a_{version}" |
| 243 | speaker_b_user_id = f"locomo_exp_user_{conv_idx}_speaker_b_{version}" |
| 244 | conv_id = f"locomo_exp_user_{conv_idx}" |
| 245 | |
| 246 | existing_results, loaded = load_existing_results(frame, version, conv_idx) |
| 247 | if loaded: |
| 248 | print(f"Loaded existing results for group {conv_idx}") |
| 249 | return existing_results |
| 250 | |
| 251 | client = None |
| 252 | if frame == "mem0" or frame == "mem0_graph": |
| 253 | from utils.client import Mem0Client |
| 254 | |
| 255 | client = Mem0Client(enable_graph="graph" in frame) |
| 256 | elif frame == "memos-api": |
| 257 | from utils.client import MemosApiClient |
| 258 | |
| 259 | client = MemosApiClient() |
| 260 | elif frame == "memos-api-online": |
| 261 | from utils.client import MemosApiOnlineClient |
| 262 | |
| 263 | client = MemosApiOnlineClient() |
| 264 | elif frame == "memobase": |
| 265 | from utils.client import MemobaseClient |
| 266 | |
| 267 | client = MemobaseClient() |
| 268 | elif frame == "memu": |
| 269 | from utils.client import MemuClient |
| 270 | |
| 271 | client = MemuClient() |
| 272 | elif frame == "supermemory": |
| 273 | from utils.client import SupermemoryClient |
| 274 | |
| 275 | client = SupermemoryClient() |
| 276 | |
| 277 | metadata = { |
| 278 | "speaker_a": speaker_a, |
| 279 | "speaker_b": speaker_b, |
| 280 | "speaker_a_user_id": speaker_a_user_id, |
| 281 | "speaker_b_user_id": speaker_b_user_id, |
| 282 | "conv_idx": conv_idx, |
| 283 | "conv_id": conv_id, |
| 284 | } |
| 285 | |
| 286 | def process_qa(qa): |
| 287 | query = qa.get("question") |
| 288 | if qa.get("category") == 5: |
| 289 | return None |
| 290 | context, duration_ms = search_query(client, query, metadata, frame, version, top_k=top_k) |
| 291 | |
| 292 | if not context: |
| 293 | print(f"No context found for query: {query}") |
no test coverage detected