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

Azure OpenAI compatibility with Instructor #338

Closed
TempoShaman opened this issue Jan 11, 2024 · 1 comment
Closed

Azure OpenAI compatibility with Instructor #338

TempoShaman opened this issue Jan 11, 2024 · 1 comment

Comments

@TempoShaman
Copy link

TempoShaman commented Jan 11, 2024

Describe the bug
When trying to use Pydantic validation class with Instructor's response_model, Azure OpenAI throws error saying that both Functions and Tools cannot be used together. I've noticed there was some push for refactoring the "function_calls.py". I've done the changes locally but it still fails.

These are versions I am currently using:
GPT_MODEL = "gpt-35-turbo-16k"
api_version="2023-12-01-preview"
openai version= 1.7.1
I've tried openai version 1.5.0, but it's the same.

Code example:

This is my validator class:

class SQLValidator(BaseModel):
    question: str
    answer: Annotated[
        str,
        BeforeValidator(
            instructor.llm_validator("SQL query must be logically and syntactically correct.", allow_override=True)
        )
    ]

and it is used here:

response = self.client.chat.completions.create(
                model=self.GPT_MODEL,
                messages=st.session_state.conversation_history,
                tools=tools,
                tool_choice="auto",
                temperature=0,
                response_model = SQLValidator,
                max_retries=2
            )

This is the error:
image

Am I doing some silly mistake or is this problem with compatibility of Azure OpenAI service with Instructor?

Edit:
I have verified that the same error goes for Non-Azure version of OpenAI as well.

@jxnl
Copy link
Collaborator

jxnl commented Jan 12, 2024

you cannot use tools and response_model together

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants