-
-
Notifications
You must be signed in to change notification settings - Fork 604
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
Return multiple choices #576
Comments
I think we can create a overload that does this thanks for the new sdk |
Will experiment with overloads. |
This was closed without merge, is this functionality working? It's a really nice feature to have if you want to extract multiple elements from a larger chunk of text, like menu items. EDIT: Reading https://python.useinstructor.com/examples/classification/#defining-the-structures_1 it seems like this can be solved by constructing your Pydantic models into a list of items: class ItemType(str, Enum):
MAIN_COURSE = "main_course"
APPETIZER = "appetizer"
DESSERT = "dessert"
DRINK = "drink"
class MenuItem(BaseModel):
name: str # Name of the menu item
item_type: ItemType # Type of menu item (e.g., main course, appetizer, etc.)
description: str # Description of the menu item
price: float # Price of the menu item
class Menu(BaseModel):
items: List[MenuItem]
In my limited testing, this works! |
Also interested in this feature |
@josepablog Did you look at the solution I posted? It seems to work very well for me. |
ohhh.. I didn't understand it at first. I'll think about it, I think I may be able to solve my issue with prompting: I'm outputting a list to begin with, and I don't think a list of lists. I am just trying to make sure that the list is long enough. thanks for getting back to me! |
Pydantic also supports minimum list lengths: https://github.com/annotated-types/annotated-types?tab=readme-ov-file#minlen-maxlen-len
|
To be clear, this feature would still be incredibly useful to have. |
Describe the solution you'd like
Thanks a lot for making this library, it's been super helpful! I am working on a text classification task and I wanted to get multiple parsed responses from a single
client.chat.completions.create
call using OpenAI's n parameter.The following would only parse the first completion I believe:
How would you recommend going on about it? Thank you!
The text was updated successfully, but these errors were encountered: