From cffbb04dca94da62e7fe1d740d7f57b5265fc67a Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 7 Sep 2023 21:12:43 -0400 Subject: [PATCH] remove patch form validator --- instructor/dsl/validators.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/instructor/dsl/validators.py b/instructor/dsl/validators.py index 10685f752..7e55d0629 100644 --- a/instructor/dsl/validators.py +++ b/instructor/dsl/validators.py @@ -3,10 +3,8 @@ import instructor import openai -instructor.patch() - -class Validator(BaseModel): +class Validator(instructor.OpenAISchema): """ Validate if an attribute is correct and if not, return a new value with an error message @@ -42,8 +40,9 @@ def llm_validator( """ def llm(v): - resp: Validator = openai.ChatCompletion.create( - response_model=Validator, + resp = openai.ChatCompletion.create( + functions=[Validator.openai_schema], + function_call={"name": Validator.openai_schema["name"]}, messages=[ { "role": "system", @@ -57,6 +56,7 @@ def llm(v): model=model, temperature=temperature, ) # type: ignore + resp = Validator.from_response(resp) # If the response is not valid, return the reason, this could be used in # the future to generate a better response, via reasking mechanism.