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

Error: "No default __reduce__ due to non-trivial __cinit__" #229

Open
madiator opened this issue Dec 7, 2024 · 0 comments
Open

Error: "No default __reduce__ due to non-trivial __cinit__" #229

madiator opened this issue Dec 7, 2024 · 0 comments

Comments

@madiator
Copy link
Contributor

madiator commented Dec 7, 2024

If you have a separate parse_func where you add type annotation to the argument, you get this strange error.

e.g.

from bespokelabs import curator
from datasets import Dataset
from pydantic import BaseModel, Field
from typing import List

# Create a dataset object for the topics you want to create the poems.
topics = Dataset.from_dict({"topic": [
    "Urban loneliness in a bustling city",
    "Beauty of Bespoke Labs's Curator library"
]})

# Define a class to encapsulate a list of poems.
class Poem(BaseModel):
    poem: str = Field(description="A poem.")

class Poems(BaseModel):
    poems_list: List[Poem] = Field(description="A list of poems.")

# removing the type annotation for `poems` works fine.
def parse_func(row, poems: Poems):
    return [
        {"topic": row["topic"], "poem": p.poem} for p in poems.poems_list
    ]

# We define a Prompter that generates poems which gets applied to the topics dataset.
poet = curator.Prompter(
    prompt_func=lambda row: f"Write two poems about {row['topic']}.",
    model_name="gpt-4o-mini",
    response_format=Poems,
    parse_func=parse_func,
)
poem = poet(topics)
print(poem.to_pandas())

Error:

TypeError                                 Traceback (most recent call last)
[<ipython-input-4-38125e72f173>](https://localhost:8080/#) in <cell line: 35>()
     33     parse_func=parse_func,
     34 )
---> 35 poem = poet(topics)
     36 print(poem.to_pandas())

136 frames
/usr/local/lib/python3.10/dist-packages/zmq/backend/cython/socket.cpython-310-x86_64-linux-gnu.so in zmq.backend.cython.socket.Socket.__reduce_cython__()

TypeError: no default __reduce__ due to non-trivial __cinit__
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

1 participant