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

Support top level List[T] type for iterable's, partial's and raw responses #1146

Open
aretrace opened this issue Nov 5, 2024 · 2 comments
Open

Comments

@aretrace
Copy link

aretrace commented Nov 5, 2024

It would be really useful to be able to return an object type of list when using client.chat.completions.create_iterable / create_partial / create_with_completion. The patched client currently only supports list with vanilla create:

class T(BaseModel):
        ...

response = client.chat.completions.create(
        model="gpt-3.5-turbo",
        messages=[
            {"role": "system", "content": "..."},
            {"role": "user", "content": "..."},
        ],
        response_model=List[T],
    )

create_with_completion would be a priority for this support (create already works).

@Mr-Ruben
Copy link

Mr-Ruben commented Dec 6, 2024

Maybe related with
#1078
#776

@AdrienBM
Copy link

Agree, the design of create_iterable is a bit odd and clashes with create_with_completion.
Imho the cleanest implementation for users would be to just allow to pass a list[BaseModel] / List[BaseModel] for responsemodel as suggested.

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

3 participants