Find answers from the community

Updated 7 months ago

Pydantic

class Clothing(BaseModel):
"""Data model for clothing items"""
name: str
product_id: int
price: float
class ClothingList(BaseModel):
"""A list of clothing items for the model to use"""
cloths: List[Clothing]
using openai agent :=== Calling Function ===
Calling function: inventory_query_engine_tool with args: {"input": "lightweight, short-sleeved linen shirt in a pastel color, such as a soft blue or mint green, for men"}
Got output: Error: 1 validation error for ClothingList
cloths
Field required [type=missing, input_value={}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.7/v/missing
========================

=== Calling Function ===
Calling function: inventory_query_engine_tool with args: {"input": "tailored chino shorts in a neutral color like beige or light grey for men"}
Got output: Error: 1 validation error for ClothingList
cloths
Field required [type=missing, input_value={}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.7/v/missing
========================

=== Calling Function ===
Calling function: inventory_query_engine_tool with args: {"input": "comfortable loafers or espadrilles for men"}
Got output: Error: 1 validation error for ClothingList
cloths
Field required [type=missing, input_value={}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.7/v/missing
========================
W
o
L
19 comments
Your llm wasn't able to parse info from the given text correctly
how can i fix it?
does that mean for the input for exemple "lightweight, short-sleeved linen shirt in a pastel color, such as a soft blue or mint green, for men" , the inventory query engine didnt get any matching ? or thats not the case?
Yea this means the LLM wasn't able to predict the output class properly
try adding better descriptions maybe

Plain Text
from pydantic.v1 import BaseModel, Field

class Clothing(BaseModel):
    """Data model for clothing items"""
    name: str = Field(description="Name of the clothing.")
    product_id: int = Field(description="Product ID of the clothing.")
    price: float = Field(description="Price of the clothing.")
But I also don't really know how you supplied these pydantic items to your agent/query engine
The vector store that the query engine is being used on should contain only name , id and price embeddings ?
this is the text in the vector store:
product_id: 1 name: Crocs Classic Lined Slingback Clogs description: description: Everybody loves the comfort of the Crocs Classic Clog — and now there’s a toasty lined version to keep the feeling going all season. The soft, fuzzy liner adds to the cushion and comfort, indoors or out. Great as a slipper, yet capable to run errands, too. Croslite™ foam construction keeps them light and easy to wear. The pivoting heel strap gives you a secure fit, or push it forward to just step in and go. The legendary Classic Clog, now with a warm, fuzzy liner Incredibly light and easy to wear Pivoting heel straps for a more secure fit Great indoors or out Customizable with Jibbitz™ charms Dual Crocs Comfort™: Blissfully supportive. Soft. Cradling comfort. color: White brand: Crocs category: Footwear product_type: flats
this is the pydantic model:
class Clothing(BaseModel):
"""Data model for clothing items"""
name: str = Field(description="Name of the clothing.")
product_id: int = Field(description="Product ID of the clothing.")


class ClothingList(BaseModel):
"""A list of clothing items for the model to use"""

cloths: List[Clothing]
using query engine:res=inventory_query_engine.query("Crocs Classic Lined Slingback Clogs")
print(res)
ValidationError: 1 validation error for ClothingList
cloths
Field required [type=missing, input_value={}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.7/v/missing
how there is a field required>
i used now gpt 4 and 3.5 turbo, the error is gone but im getting empty dictionnary now even though im writing the same name of products existing in the vector store
I think there is a problem with the pydantic parsing,I Used the llama index tutorial about Paul Graham with biography basemodel and im getting empty dictionnary
i remove the base model its working properly
The output parser is working only whith completion program
with any type of query engine its giving empty dictionnary
Add a reply
Sign up and join the conversation on Discord