-
I have touched on this in #228, though this might be an entirely unrelated issue: I wrote a short progam, but there are neither errors nor parsed entities in the output, so I needed to do parsing myself: class EntityExtraction(BaseModel):
name: Optional[List[str]] = Field(
default=None,
description="names (e.g., 'Luke Skywalker', 'Obi-Wan Kenobi')."
)
location: Optional[List[str]] = Field(
default=None,
description="Location (e.g., 'Death Star', 'Coruscant')."
)
schema, validator = from_pydantic(EntityExtraction)
chain = create_extraction_chain(llm, schema, encoder_or_encoder_class="json", validator=validator)
json_encoder = JSONEncoder(use_tags=True)
result = chain.invoke(text_input.text)
return json_encoder.decode(result['text']['raw']) Is this a bug, or am I missing something obvious here? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
'raw' is not validated output. it's raw output from the LLM. The validated output is available on the 'validated' output. 'validated' will be empty if the LLM is not able to produce correctly structured output. |
Beta Was this translation helpful? Give feedback.
-
Here is an example result from my application: {'text': {'data': {'entity_extraction': {'NAME': ['Luke Skywalker'], 'LOCATION': ['Coruscant']}}, 'raw': '<json>{"entity_extraction": {"NAME": ["Luke Skywalker"], "LOCATION": ["Coruscant"]}}</json>', 'errors': [], 'validated_data': {}}} How is correctly structured output defined? Shouldn't there be an error if that is the case? |
Beta Was this translation helpful? Give feedback.
'raw' is not validated output. it's raw output from the LLM. The validated output is available on the 'validated' output. 'validated' will be empty if the LLM is not able to produce correctly structured output.