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

extract by chunk is not working #31

Open
zarlicho opened this issue Oct 23, 2024 · 1 comment
Open

extract by chunk is not working #31

zarlicho opened this issue Oct 23, 2024 · 1 comment

Comments

@zarlicho
Copy link

I want to extract a chunk from json with the extract_from_chunk() function but I get an error like this ({'chunk_index': 4, 'source': 'pdf', 'error': "'list' object has no attribute 'to_message'"}, 0)

print(thepipe.extract.extract_from_chunk(chunk=chunk,chunk_index=4,schema="bill_name",ai_model='openai/gpt-40',source='pdf',multiple_extractions=True,extraction_prompt=prompting,host_images=True))

@emcf
Copy link
Owner

emcf commented Oct 28, 2024

extract_from_chunk expects a single chunk object, not a list. Also, be sure to pass a dictionary in as the schema, not a string.
To avoid this type of issue you can actually specify the chunking method inside the extraction function:

from thepipe.chunker import chunk_by_page
 
results = extract_from_file(
    "example.pdf",
    schema={"section_title": "string", "content": "string"},
    chunking_method=chunk_by_page
)

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
@emcf @zarlicho and others