init: llm-wiki-haness 하네스 설계
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
from pydantic import BaseModel
|
||||
from deep_research.backends.base import AgentBackend
|
||||
|
||||
|
||||
class MockBackend(AgentBackend):
|
||||
"""테스트 더블. label prefix -> 응답객체(또는 None) 매핑. 네트워크·subprocess 0.
|
||||
|
||||
responses 의 키는 label prefix. 가장 먼저 매칭되는 prefix 의 값을 반환.
|
||||
값이 콜러블이면 (prompt, label) 로 호출해 동적 응답 가능."""
|
||||
|
||||
def __init__(self, responses: dict, default=None):
|
||||
self.responses = responses
|
||||
self.default = default
|
||||
self.calls: list[str] = []
|
||||
|
||||
async def run_agent(self, prompt: str, schema: type[BaseModel], *, label: str):
|
||||
self.calls.append(label)
|
||||
for prefix, resp in self.responses.items():
|
||||
if label.startswith(prefix):
|
||||
return resp(prompt, label) if callable(resp) else resp
|
||||
return self.default
|
||||
Reference in New Issue
Block a user