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

[Question]: SchemaLLMPathExtractor w/ Sonnet Fails for some Schemas #17303

Open
1 task done
kevin-yang-racap opened this issue Dec 17, 2024 · 3 comments
Open
1 task done
Labels
question Further information is requested

Comments

@kevin-yang-racap
Copy link
Contributor

Question Validation

  • I have searched both the documentation and discord for an answer.

Question

Hi, I am trying to get a SchemaLLMPathExtractor set up but I keep running into an assertion error with the kg_schema. The issue was actually the kg_schema is set to ```
'1 validation error for KGSchema
triplets
Field required [type=missing, input_value={}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.9/v/missing'

is there anything I can do to fix this error?

I am using AWS Bedrock Claude 3 Sonnet.

I tried with a simpler schema and it works fine.
@kevin-yang-racap kevin-yang-racap added the question Further information is requested label Dec 17, 2024
Copy link

dosubot bot commented Dec 17, 2024

To fix the assertion error related to the missing 'triplets' field in the kg_schema, ensure that the kg_schema_cls is correctly initialized with the triplets field. The triplets field should be a list of triplet_cls instances. Here's a snippet of the relevant code setup:

triplet_cls = create_model(
    "Triplet",
    subject=(entity_cls, ...),
    relation=(relation_cls, ...),
    object=(entity_cls, ...),
)

root = field_validator("triplets", mode="before")(validate)
kg_schema_cls = create_model(
    "KGSchema",
    __validators__={"validator1": root},  # type: ignore
    triplets=(List[triplet_cls], ...),  # type: ignore
)

Make sure that when you instantiate kg_schema_cls, you provide a list of triplets that conform to the triplet_cls model. This should resolve the assertion error by ensuring the triplets field is present and correctly formatted [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@logan-markewich
Copy link
Collaborator

This quite literally means the llm did not output the proper/expected schema

Maybe try a different extractor

@kevin-yang-racap
Copy link
Contributor Author

I want to use the SchemaLLMPathExtractor's fixed schema rather than use the DynamicLLMPathExtractor.

Does the pydantic check for partially filled out schema? Is there a way to see what the LLM returned to debug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants