Skip to content

Commit afed495

Browse files
authored
Merge pull request #21 from AdrianLipa90/codex/scan-repository-for-core-module-locations
Add language backend integration test
2 parents de4c068 + 3d3fa2d commit afed495

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from typing import Any, Dict, List
2+
3+
from ciel import CielEngine
4+
from ciel.language_backend import AuxiliaryBackend, LanguageBackend
5+
6+
7+
class DummyPrimary(LanguageBackend):
8+
def __init__(self) -> None:
9+
self.name = "dummy-primary"
10+
11+
def generate_reply(
12+
self,
13+
dialogue: List[Dict[str, str]],
14+
ciel_state: Dict[str, Any],
15+
) -> str:
16+
return "dummy reply"
17+
18+
19+
class DummyAux(AuxiliaryBackend):
20+
def __init__(self) -> None:
21+
self.name = "dummy-aux"
22+
23+
def analyse_state(
24+
self,
25+
ciel_state: Dict[str, Any],
26+
candidate_reply: str,
27+
) -> Dict[str, Any]:
28+
return {"score": 0.99, "label": "test"}
29+
30+
31+
def test_language_backend_interact_with_dummies():
32+
engine = CielEngine()
33+
engine.language_backend = DummyPrimary()
34+
engine.aux_backend = DummyAux()
35+
36+
result = engine.interact(
37+
"hello",
38+
dialogue=[{"role": "user", "content": "hello"}],
39+
)
40+
41+
assert result["status"] == "ok"
42+
assert result["reply"] == "dummy reply"
43+
assert "analysis" in result
44+
assert "ciel_state" in result

0 commit comments

Comments
 (0)