Skip to content
Discussion options

You must be logged in to vote
# Union of Search, Lookup, and Finish
class TakeAction(BaseModel):
    action: Union[Search, Lookup, Finish]

    def process(self):
        """Process the action."""
        return self.action.process()


# Enables `response_model`
client = instructor.patch(OpenAI())

action = client.chat.completions.create(
    model="gpt-3.5-turbo",
    response_model=TakeAction,
    messages=[
        {"role": "user", "content": "I need to find information about Python"},
    ],
)

Replies: 3 comments 9 replies

Comment options

You must be logged in to vote
7 replies
@zby
Comment options

@zby
Comment options

@jxnl
Comment options

jxnl Dec 22, 2023
Maintainer

@jxnl
Comment options

jxnl Dec 22, 2023
Maintainer

Answer selected by zby
@zby
Comment options

@jxnl
Comment options

jxnl Dec 22, 2023
Maintainer

@zby
Comment options

Comment options

You must be logged in to vote
2 replies
@jxnl
Comment options

jxnl Dec 25, 2023
Maintainer

@zby
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants