MCPcopy Create free account
hub / github.com/Claw-AI-Lab/Claw-AI-Lab / FakeLLM

Class FakeLLM

backend/agent/tests/test_code_agent.py:28–43  ·  view source on GitHub ↗

Fake LLM client that returns configurable responses.

Source from the content-addressed store, hash-verified

26
27
28class FakeLLM:
29 """Fake LLM client that returns configurable responses."""
30
31 def __init__(self, responses: list[str] | None = None):
32 self.calls: list[dict[str, Any]] = []
33 self._responses = list(responses or [])
34 self._call_idx = 0
35
36 def chat(self, messages: list[dict], **kwargs: Any) -> LLMResponse:
37 self.calls.append({"messages": messages, **kwargs})
38 if self._responses:
39 text = self._responses[min(self._call_idx, len(self._responses) - 1)]
40 else:
41 text = '```filename:main.py\nprint("hello")\n```'
42 self._call_idx += 1
43 return LLMResponse(content=text, model="fake-model")
44
45
46@dataclass

Calls

no outgoing calls