Skip to content

Commit 711b27d

Browse files
committed
fixed imports and tests
1 parent 5b3a559 commit 711b27d

2 files changed

Lines changed: 2 additions & 48 deletions

File tree

tests/test_handlers_llm.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
from collections.abc import Callable
22
from typing import Annotated
33

4-
import pytest
5-
64
from effectful.handlers.llm import Template
7-
from effectful.handlers.llm.synthesis import ProgramSynthesis
85
from effectful.handlers.llm.template import IsRecursive
96
from effectful.ops.semantics import NotHandled, handler
107
from effectful.ops.syntax import ObjectInterpretation, implements
@@ -119,22 +116,6 @@ def test_primes_decode_int():
119116
assert isinstance(result, int)
120117

121118

122-
@pytest.mark.xfail(reason="Synthesis handler not yet implemented")
123-
def test_count_char_with_program_synthesis():
124-
"""Test the count_char template with program synthesis."""
125-
mock_code = """<code>
126-
def count_occurrences(s):
127-
return s.count('a')
128-
</code>"""
129-
mock_provider = SingleResponseLLMProvider(mock_code)
130-
131-
with handler(mock_provider), handler(ProgramSynthesis()):
132-
count_a = count_char("a")
133-
assert callable(count_a)
134-
assert count_a("banana") == 3
135-
assert count_a("cherry") == 0
136-
137-
138119
class FailingThenSucceedingProvider[T](ObjectInterpretation):
139120
"""Mock provider that fails a specified number of times before succeeding."""
140121

tests/test_handlers_llm_provider.py

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
import functools
8+
import inspect
89
import json
910
import os
1011
from collections.abc import Callable
@@ -25,8 +26,8 @@
2526
call_assistant,
2627
completion,
2728
)
29+
from effectful.handlers.llm.encoding import Encodable, SynthesizedFunction
2830
from effectful.handlers.llm.evaluation import UnsafeEvalProvider
29-
from effectful.handlers.llm.synthesis import ProgramSynthesis, SynthesisError
3031
from effectful.ops.semantics import fwd, handler
3132
from effectful.ops.syntax import ObjectInterpretation, implements
3233
from effectful.ops.types import NotHandled
@@ -241,29 +242,6 @@ def test_with_config_params(self, request):
241242
assert isinstance(result, str)
242243

243244

244-
@pytest.mark.xfail(reason="Program synthesis not implemented")
245-
class TestProgramSynthesis:
246-
"""Tests for ProgramSynthesis handler functionality."""
247-
248-
@pytest.mark.xfail
249-
@requires_openai
250-
@retry_on_error(error=SynthesisError, n=3)
251-
def test_generates_callable(self, request):
252-
"""Test ProgramSynthesis handler generates executable code."""
253-
with (
254-
handler(ReplayLiteLLMProvider(request, model="gpt-4o-mini")),
255-
handler(ProgramSynthesis()),
256-
handler(LimitLLMCallsHandler(max_calls=1)),
257-
):
258-
count_func = create_function("a")
259-
260-
assert callable(count_func)
261-
# Test the generated function
262-
assert count_func("banana") == 3
263-
assert count_func("cherry") == 0
264-
assert count_func("aardvark") == 3
265-
266-
267245
def smiley_face() -> Image.Image:
268246
bmp = [
269247
"00000000",
@@ -473,7 +451,6 @@ def test_synthesize_counter_with_parameter(self, request):
473451
@requires_openai
474452
def test_callable_type_signature_in_schema(self, request):
475453
"""Test that the callable type signature is communicated to the LLM."""
476-
from effectful.handlers.llm.encoding import Encodable
477454

478455
# Verify that the enc type includes the signature in its docstring
479456
encodable = Encodable.define(Callable[[int, int], int], {})
@@ -487,8 +464,6 @@ def test_callable_type_signature_in_schema(self, request):
487464
@requires_openai
488465
def test_synthesized_function_roundtrip(self, request):
489466
"""Test that a synthesized function can be encoded and decoded."""
490-
from effectful.handlers.llm.encoding import Encodable
491-
from effectful.handlers.llm.synthesis import SynthesizedFunction
492467

493468
with (
494469
handler(ReplayLiteLLMProvider(request, model="gpt-4o-mini")),
@@ -513,7 +488,6 @@ def test_synthesized_function_roundtrip(self, request):
513488
@requires_openai
514489
def test_synthesize_bool_return_type(self, request):
515490
"""Test that LLM respects bool return type in signature."""
516-
import inspect
517491

518492
with (
519493
handler(ReplayLiteLLMProvider(request, model="gpt-4o-mini")),
@@ -536,7 +510,6 @@ def test_synthesize_bool_return_type(self, request):
536510
@requires_openai
537511
def test_synthesize_three_params(self, request):
538512
"""Test that LLM respects the exact number of parameters in signature."""
539-
import inspect
540513

541514
with (
542515
handler(ReplayLiteLLMProvider(request, model="gpt-4o-mini")),

0 commit comments

Comments
 (0)