| 43 | self.config: MockLMConfig = config |
| 44 | |
| 45 | def _response(self, msg: str) -> LLMResponse: |
| 46 | # response is based on this fallback order: |
| 47 | # - response_dict |
| 48 | # - response_fn |
| 49 | # - default_response |
| 50 | mapped_response = self.config.response_dict.get( |
| 51 | msg, self.config.response_fn(msg) or self.config.default_response |
| 52 | ) |
| 53 | return lm.LLMResponse( |
| 54 | message=to_string(mapped_response), |
| 55 | cached=False, |
| 56 | ) |
| 57 | |
| 58 | async def _response_async(self, msg: str) -> LLMResponse: |
| 59 | # response is based on this fallback order: |