Is the result from a Responder (i.e. an entity or sub-task) such that we can stop searching for responses in this step?
(
self,
result: Optional[ChatDocument],
r: Responder,
)
| 2098 | return (final, StatusCode.OK) |
| 2099 | |
| 2100 | def valid( |
| 2101 | self, |
| 2102 | result: Optional[ChatDocument], |
| 2103 | r: Responder, |
| 2104 | ) -> bool: |
| 2105 | """ |
| 2106 | Is the result from a Responder (i.e. an entity or sub-task) |
| 2107 | such that we can stop searching for responses in this step? |
| 2108 | """ |
| 2109 | # TODO caution we should ensure that no handler method (tool) returns simply |
| 2110 | # an empty string (e.g when showing contents of an empty file), since that |
| 2111 | # would be considered an invalid response, and other responders will wrongly |
| 2112 | # be given a chance to respond. |
| 2113 | |
| 2114 | # if task would be considered done given responder r's `result`, |
| 2115 | # then consider the result valid. |
| 2116 | if result is not None and self.done(result, r)[0]: |
| 2117 | return True |
| 2118 | return ( |
| 2119 | result is not None |
| 2120 | and not self._is_empty_message(result) |
| 2121 | # some weaker LLMs, including even GPT-4o, may say "DO-NOT-KNOW." |
| 2122 | # (with a punctuation at the end), so need to strip out punctuation |
| 2123 | and re.sub(r"[,.!?:]", "", result.content.strip()) != NO_ANSWER |
| 2124 | ) |
| 2125 | |
| 2126 | def log_message( |
| 2127 | self, |
no test coverage detected