You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Instructor with Anthropic/Claude model, I'm encountering validation errors where the LLM returns single float values instead of expected List[Object] structures.
Code Example
# ModelsclassRecipeStep(BaseModel):
step_number: str=Field(..., description="Step number in the cooking process")
duration: str=Field(..., description="Time required for this step")
temperature: float=Field(..., description="Required temperature")
classCookingMethod(BaseModel):
method_name: str=Field(..., description="Name of cooking method")
steps: List[RecipeStep] =Field(..., description="Details of cooking steps")
classDishDetails(BaseModel):
dish_name: str=Field(..., description="Name of the dish")
cooking_approaches: List[CookingMethod]
classRecipeResponse(BaseModel):
chef_explanation: strdish_details: List[DishDetails]
# Usageresponse=anthropic_client.create(
model="claude-3-sonnet-20240229",
messages=[{"role": "user", "content": content}],
response_model=RecipeResponse
)
Error Message
instructor.exceptions.InstructorRetryException: 15 validation errors for RecipeResponse
dish_details.0.cooking_approaches.0.steps
Input should be a valid array [type=list_type, input_value=350.5, input_type=float]
Expected Behavior
The LLM should return a properly structured object with steps as a List[RecipeStep] containing step objects with number, duration, and temperature.
Actual Behavior
Instead, the LLM is returning single float values where List[RecipeStep] is expected.
Environment
instructor version: 1.7.2
pydantic version: 2.10.6
Python version: 3.12
Model: Claude 3.5 V2 through AnthropicBedrock
Question
Is this a known limitation with the current implementation?
Are there recommended approaches to enforce the expected list structure?
Any guidance would be appreciated!
The text was updated successfully, but these errors were encountered:
Issue Description
When using Instructor with Anthropic/Claude model, I'm encountering validation errors where the LLM returns single float values instead of expected List[Object] structures.
Code Example
Error Message
Expected Behavior
The LLM should return a properly structured object with steps as a List[RecipeStep] containing step objects with number, duration, and temperature.
Actual Behavior
Instead, the LLM is returning single float values where List[RecipeStep] is expected.
Environment
Question
Any guidance would be appreciated!
The text was updated successfully, but these errors were encountered: