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

create_iterable is broken #668

Open
bryanhpchiang opened this issue May 14, 2024 · 3 comments
Open

create_iterable is broken #668

bryanhpchiang opened this issue May 14, 2024 · 3 comments

Comments

@bryanhpchiang
Copy link

create_iterable from the docs does not work.

  1. Go here: https://python.useinstructor.com/#streaming-iterables-create_iterable
  2. Copy + paste + run the example
  3. Error
Traceback (most recent call last):
  File "/Users/bryan/work/flow/iterable.py", line 14, in <module>
    users = client.chat.completions.create_iterable(
  File "/Users/bryan/work/flow/.venv/lib/python3.10/site-packages/instructor/client.py", line 184, in create_iterable
    return self.create_fn(
  File "/Users/bryan/work/flow/.venv/lib/python3.10/site-packages/instructor/patch.py", line 140, in new_create_sync
    response_model, new_kwargs = handle_response_model(
  File "/Users/bryan/work/flow/.venv/lib/python3.10/site-packages/instructor/process_response.py", line 191, in handle_response_model
    if is_simple_type(response_model):
  File "/Users/bryan/work/flow/.venv/lib/python3.10/site-packages/instructor/dsl/simple_type.py", line 40, in is_simple_type
    if isclass(response_model) and issubclass(response_model, BaseModel):
  File "/Users/bryan/miniconda3/envs/turbo/lib/python3.10/abc.py", line 123, in __subclasscheck__
    return _abc_subclasscheck(cls, subclass)
TypeError: issubclass() arg 1 must be a class
(turbo) bryan@Bryans-MacBook-Pro-7 flow % python -V
Python 3.10.12
(turbo) bryan@Bryans-MacBook-Pro-7 flow % pip show openai
Name: openai
Version: 1.30.1
Summary: The official Python library for the openai API
Home-page:
Author:
Author-email: OpenAI <support@openai.com>
License:
Location: /Users/bryan/miniconda3/envs/turbo/lib/python3.10/site-packages
Requires: anyio, distro, httpx, pydantic, sniffio, tqdm, typing-extensions
Required-by: instructor, litellm, open-interpreter, self-operating-computer
(turbo) bryan@Bryans-MacBook-Pro-7 flow % pip show instructor
Name: instructor
Version: 1.2.6
Summary: structured outputs for llm
Home-page: https://github.com/jxnl/instructor
Author: Jason Liu
Author-email: jason@jxnl.co
License: MIT
Location: /Users/bryan/miniconda3/envs/turbo/lib/python3.10/site-packages
Requires: aiohttp, docstring-parser, openai, pydantic, pydantic-core, rich, tenacity, typer
Required-by:
(turbo) bryan@Bryans-MacBook-Pro-7 flow %
@shaunstoltz
Copy link

shaunstoltz commented May 17, 2024

Same for me:

    client = instructor.from_litellm(completion)


   completion_return = client.chat.completions.create_iterable(
        messages=[{"role": "user", "content": prompt}],
        response_model=task_decomp,
        model=model,
      )

Error: issubclass() arg 1 must be a class

class task_decomp(BaseModel):
    index: int
    description: str
    duration: int
    left: int

@loubnaelattar
Copy link

i am facing the same issue, have you figured out how to fix it?

@jxnl
Copy link
Owner

jxnl commented May 23, 2024

will explore more!

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

4 participants