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,
)
| 93 | return "".join(paragraphs) |
| 94 | |
| 95 | async def _process_inputs( |
| 96 | self, |
| 97 | raw_inputs:Dict[str,str], |
| 98 | spatial_info:Dict[str,Any], |
| 99 | temporal_info:Dict[str,Any], |
| 100 | mode: str = "default", |
| 101 | **kwargs, |
| 102 | )->Dict[str, Any]: |
| 103 | """ To be overriden by the descendant class """ |
| 104 | """ Process the raw_inputs(most of the time is a List[Dict]) """ |
| 105 | |
| 106 | if mode == "allow_kv_reuse": |
| 107 | request_uid = raw_inputs.get("_request_uid") or kwargs.get("request_uid") |
| 108 | if request_uid is None: |
| 109 | raise ValueError("request_uid is required for request-scoped anchor updates.") |
| 110 | |
| 111 | preferred_mode = "kv_reuse" |
| 112 | agent_memory = self.llm._ensure_agent_memory(self.id) |
| 113 | prefix_text = kwargs.get("prefix", "") |
| 114 | |
| 115 | has_shared_prefix = ( |
| 116 | self.llm.has_prefix_initialized(self.id) |
| 117 | and "placeholder_info" in agent_memory |
| 118 | ) |
| 119 | early_response: str | None = None |
| 120 | |
| 121 | if has_shared_prefix: |
| 122 | task = raw_inputs["task"] |
| 123 | for agent_id, info in spatial_info.items(): |
| 124 | cond_text: str | None = None |
| 125 | cond_prefix: str | None = None |
| 126 | |
| 127 | if self.domain == "gsm8k" and info["role"] == "Programming Expert": |
| 128 | answer = execute_code_get_return( |
| 129 | info["output"].split("```python\n")[-1].split("\n```")[0] |
| 130 | ) |
| 131 | if answer is None: |
| 132 | answer = "No variable is named answer." |
| 133 | cond_text = f"the answer is {answer}" |
| 134 | cond_prefix = "the answer is " |
| 135 | elif ( |
| 136 | self.domain == "humaneval" |
| 137 | and self.role not in {"Normal Programmer", "Stupid Programmer"} |
| 138 | and info["role"] != "Algorithm Designer" |
| 139 | ): |
| 140 | code = info["output"].split("```python\n")[-1].split("\n```")[0] |
| 141 | is_solved, feedback, _ = PyExecutor().execute( |
| 142 | code, getattr(self, "internal_tests", []), timeout=10 |
| 143 | ) |
| 144 | cond_text = ( |
| 145 | "Whether it passes internal testing?\n" |
| 146 | f"{is_solved}.\n\nThe feedback is:\n\n {feedback}." |
| 147 | ) |
| 148 | cond_prefix = "Whether it passes internal testing?\n" |
| 149 | |
| 150 | if cond_text and cond_prefix: |
| 151 | self.llm.update_condition_anchor( |
| 152 | request_uid=request_uid, |
no test coverage detected