Giter Site home page Giter Site logo

Comments (9)

shaunstoltz avatar shaunstoltz commented on June 18, 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

from instructor.

loubnaelattar avatar loubnaelattar commented on June 18, 2024

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

from instructor.

jxnl avatar jxnl commented on June 18, 2024

will explore more!

from instructor.

jlondonobo avatar jlondonobo commented on June 18, 2024

This issue was fixed in #710, with the relevant changes found here:

try:
if isclass(response_model) and issubclass(response_model, BaseModel):
return False
except TypeError:
# ! In versions < 3.11, typing.Iterable is not a class, so we can't use isclass
# ! for now if `response_model` is an Iterable isclass and issubclass will raise
# ! TypeError, so we need to check if `response_model` is an Iterable
# ! This is a workaround for now, we should fix this in later PRs
return False

I’ve verified that the example now runs without any problems. It’s safe to close this issue.

from instructor.

ig-freetech avatar ig-freetech commented on June 18, 2024

I still face the same problem and the error happens like below in version 1.3.2 (latest).

issubclass() arg 1 must be a class ... TypeError: issubclass() arg 1 must be a class

スクリーンショット 2024-06-07 3 18 43 スクリーンショット 2024-06-07 3 20 17
class GeminiClient:
    def __init__(self):
        genai.configure(api_key=GOOGLE_API_KEY)
        self.model = client_gemini.from_gemini(
            client=genai.GenerativeModel(model_name="models/gemini-1.5-flash-latest"),
            mode=Mode.GEMINI_JSON
        )

class ScenarioTelop(BaseModel):
    telop_id: int = Field(description="Order of the telop (starting from 1)")
    overview: str = Field(description="Overview of the telop")
    intention: str = Field(description="Intention of the telop")
    text: str = Field(description="Corrected text of the telop")
    original_text: str = Field(description="Original text of the telop")
    timestamp_start: float = Field(description="Start timestamp of the telop (s)")
    timestamp_end: float = Field(description="End timestamp of the telop (s)")

from instructor.

jxnl avatar jxnl commented on June 18, 2024

what version of python are you on?

from instructor.

ig-freetech avatar ig-freetech commented on June 18, 2024

what version of python are you on?

3.9.18

from instructor.

ivanleomk avatar ivanleomk commented on June 18, 2024

Proposed a potential fix for this #737 - can't seem to get the 3.11 coverage step to pass for some reason but the iterable fix is shown to work in 3.9,3.10 and 3.11

from instructor.

ivanleomk avatar ivanleomk commented on June 18, 2024

Fixed in #737

from instructor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.