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
I know this data can be found in the raw response.
user, completion = client.chat.completions.create_with_completion(
model="gpt-3.5-turbo",
response_model=UserExtract,
messages=[
{"role": "user", "content": "Extract jason is 25 years old"},
],
tool_choice="auto"
)
tool_call = completion.choices[0].message.tool_calls[0].dict()
But when allowing for multiple tools, this doesn't work:
from typing import Iterable, Literal, Union
import instructor
from openai import OpenAI
from pydantic import BaseModel
client = instructor.from_openai(OpenAI())
class UserExtract(BaseModel):
name: str
age: int
class MovieExtract(BaseModel):
movie: str
year: int
user, completion = client.chat.completions.create_with_completion(
model="gpt-3.5-turbo",
response_model=Union[UserExtract, MovieExtract],
messages=[
{"role": "user", "content": "Extract jason is 25 years old"},
],
tool_choice="auto"
)
tool_call = completion.choices[0].message.tool_calls[0].dict()
>> AttributeError: 'UserExtract' object has no attribute '_raw_response'
More generally, I'm wondering how Instructor users work with chat message history.
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
-
Does Instructor have any utils for managing messages? Specifically asking about how to format an assistant message that invoked a tool.
I'd like to store assistant messages that used tools in the conversation history. Should end up something like this.
I know this data can be found in the raw response.
But when allowing for multiple tools, this doesn't work:
More generally, I'm wondering how Instructor users work with chat message history.
Beta Was this translation helpful? Give feedback.
All reactions