You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Forgive me if it is in the documentation (couldn't find it), but what is the point of having 2 ways to instantiate the client
# Normal Toolsclient=instructor.from_openai(openai.OpenAI(),
mode=instructor.Mode.TOOLS,
)
# Parallel Toolsclient=instructor.from_openai(openai.OpenAI(),
mode=instructor.Mode.PARALLEL_TOOLS,
)
if you can obtain a full_response AND multiple calls (= tools) just by making the response_model class an Iterable?
classUserExtract(BaseModel):
name: strage: intclassMovieExtract(BaseModel):
movie: stryear: int# Create a class that has an Iterable of classes (to allow Multiple Tools)classOutput(BaseModel):
#results: Union[UserExtract, MovieExtract] # Before, just one OR the otherresults: Iterable[Union[UserExtract, MovieExtract]] # Now, any number
With this you obtain full response + multiple tools
# Call APIoutput, assistant_message_response=client.chat.completions.create_with_completion(
model="gpt-3.5-turbo",
response_model=Output,
messages=[
{"role": "user", "content": "Jason is a guy of 25 years old. Today he is watching `Titanic (2002)`"},
],
)
# Displayforcallinoutput.results:
call# UserExtract(name='Jason', age=25)# MovieExtract(movie='Titanic', year=2002)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Forgive me if it is in the documentation (couldn't find it), but what is the point of having 2 ways to instantiate the client
if you can obtain a full_response AND multiple calls (= tools) just by making the response_model class an
Iterable
?With this you obtain full response + multiple tools
Beta Was this translation helpful? Give feedback.
All reactions