Fix Encodable for Dataclass and Scalar in #548#571
Fix Encodable for Dataclass and Scalar in #548#571datvo06 wants to merge 5 commits intoeb-remove-responsefrom
Conversation
|
I found some failure tests. Checking more before re-opening |
|
The problem is the traces being replayed, which use the old |
Yes. Fixtures are part of it, but also these following cases now fail, which I think because of this comment #548 (comment) (we dropped the default @Template.define
def primes(first_digit: int) -> int:
"""Give a prime number with {first_digit} as the first digit. Do not use any tools."""
raise NotHandled
with handler(provider):
assert type(primes(6)) is intResult: APIConnectionError: litellm.APIConnectionError: APIConnectionError: OpenAIException - Unsupported response_format type - <class 'int'>And this: @dataclasses.dataclass
class KnockKnockJoke:
whos_there: str
punchline: str
@Template.define
def write_joke(theme: str) -> KnockKnockJoke:
"""Write a knock-knock joke on the theme of {theme}. Do not use any tools."""
raise NotHandled
@Template.define
def rate_joke(joke: KnockKnockJoke) -> bool:
"""Decide if {joke} is funny or not. Do not use any tools."""
raise NotHandled
def do_comedy():
joke = write_joke("lizards")
print("> You are onstage at a comedy club. You tell the following joke:")
print(
f"Knock knock.\nWho's there?\n{joke.whos_there}.\n{joke.whos_there} who?\n{joke.punchline}"
)
if rate_joke(joke):
print("> The crowd laughs politely.")
else:
print("> The crowd stares in stony silence.")
with handler(provider):
do_comedy()Result: APIConnectionError: litellm.APIConnectionError: APIConnectionError: OpenAIException - Unsupported response_format type - <class '__main__.KnockKnockJoke'> |
|
The solution is not to handle scalars or dataclasses or other types that can theoretically be coerced into Pydantic piecemeal, but to do the encoding generically in the base case of |
I see, I think we can make encoding more generic is adding |
This PR: