To be overriden by the descendant class
(
self,
raw_inputs:Dict[str,str],
spatial_info:Dict[str,Any],
temporal_info:Dict[str,Any],
mode: str = "default",
**kwargs,
)
| 351 | self.prompt_set = PromptSetRegistry.get(domain) |
| 352 | |
| 353 | async def _process_inputs( |
| 354 | self, |
| 355 | raw_inputs:Dict[str,str], |
| 356 | spatial_info:Dict[str,Any], |
| 357 | temporal_info:Dict[str,Any], |
| 358 | mode: str = "default", |
| 359 | **kwargs, |
| 360 | )->Dict[str, Any]: |
| 361 | """ To be overriden by the descendant class """ |
| 362 | """ Process the raw_inputs(most of the time is a List[Dict]) """ |
| 363 | if mode == "allow_kv_reuse": |
| 364 | request_uid = raw_inputs.get("_request_uid") or kwargs.get("request_uid") |
| 365 | if request_uid is None: |
| 366 | raise ValueError("request_uid is required for request-scoped anchor updates.") |
| 367 | |
| 368 | preferred_mode = "kv_reuse" |
| 369 | agent_memory = self.llm._ensure_agent_memory(self.id) |
| 370 | prefix_text = kwargs.get("prefix", "") |
| 371 | |
| 372 | has_shared_prefix = ( |
| 373 | self.llm.has_prefix_initialized(self.id) |
| 374 | and "placeholder_info" in agent_memory |
| 375 | ) |
| 376 | early_response: str | None = None |
| 377 | |
| 378 | if has_shared_prefix: |
| 379 | task = raw_inputs["task"] |
| 380 | for agent_id, info in spatial_info.items(): |
| 381 | cond_text: str | None = None |
| 382 | cond_prefix: str | None = None |
| 383 | |
| 384 | if self.domain == "gsm8k" and info["role"] == "Programming Expert": |
| 385 | answer = execute_code_get_return( |
| 386 | info["output"].split("```python\n")[-1].split("\n```")[0] |
| 387 | ) |
| 388 | if answer is None: |
| 389 | answer = "No variable is named answer." |
| 390 | cond_text = f"the answer is {answer}" |
| 391 | cond_prefix = "the answer is " |
| 392 | elif ( |
| 393 | self.domain == "humaneval" |
| 394 | and self.role not in {"Normal Programmer", "Stupid Programmer"} |
| 395 | and info["role"] != "Algorithm Designer" |
| 396 | ): |
| 397 | code = info["output"].split("```python\n")[-1].split("\n```")[0] |
| 398 | is_solved, feedback, _ = PyExecutor().execute( |
| 399 | code, getattr(self, "internal_tests", []), timeout=10 |
| 400 | ) |
| 401 | cond_text = ( |
| 402 | "Whether it passes internal testing?\n" |
| 403 | f"{is_solved}.\n\nThe feedback is:\n\n {feedback}." |
| 404 | ) |
| 405 | cond_prefix = "Whether it passes internal testing?\n" |
| 406 | |
| 407 | if cond_text and cond_prefix: |
| 408 | self.llm.update_condition_anchor( |
| 409 | request_uid=request_uid, |
| 410 | owner_agent_id=agent_id, |
no test coverage detected