Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Python translator fixes #246

Merged
merged 10 commits into from
Apr 30, 2024
Prev Previous commit
Next Next commit
Add test for invalid JSON responses.
DanielRosenwasser committed Apr 30, 2024
commit 0e6329f2f7c9323d2b649e9a9c19db22b22b096a
10 changes: 10 additions & 0 deletions python/tests/test_translator.py
Original file line number Diff line number Diff line change
@@ -52,6 +52,16 @@ def test_translator_with_single_failure(snapshot: Any):

assert m.conversation == snapshot

def test_translator_with_invalid_json(snapshot: Any):
m = FixedModel([
'{ "a": "hello" "b": true }',
'{ "a": "hello" "b": true, "c": 1234 }',
])
t = typechat.TypeChatJsonTranslator(m, v, ExampleABC)
asyncio.run(t.translate("Get me stuff."))

assert m.conversation == snapshot

def test_translator_with_single_failure_and_str_preamble(snapshot: Any):
m = FixedModel([
'{ "a": "hello", "b": true }',