Replies: 2 comments 5 replies
-
Hello.
class UserDetail(BaseModel):
age: int = Field(description="Age of the user", exclude=True)
name: str
print(UserDetail.model_json_schema())
"""Prints the FULL schema, age included."""
print(UserDetail(age=33, name='aaa').model_dump_json())
"""Prints name only.""" Instructor obviously uses the schema definition to pass the LLM, hence "exclude" does not work to hide fields. All the workarounds I can think of are quire convoluted: e.g. one could only have the necessary fields in the schema definition and override the call method of the model where one includes the extra arguments. This means there is the extra step of calling this method after the initial model validation. Not sure if there's a better/faster way. I can show you my initial workaround (which requires a local version of instructor though.. which is not ideal I'd say) |
Beta Was this translation helpful? Give feedback.
-
The purpose of fields with
Although you probably wont want to embed the actual task as above, it serves as an example of how you can embed specific instructions, examples, chain of though, etc. straight within the schema, instead of having to use argstrings or more complex data models when it's not necessary. |
Beta Was this translation helpful? Give feedback.
-
I may have misunderstood the purpose of exclude but it appears that even fields marked with exclude=True are still sent to the LLM as required, and the LLM responds accordingly with these values. It appears that these are then ignored by Instructor, but wouldn't it have been better to save on the tokens and not send them at all?
Beta Was this translation helpful? Give feedback.
All reactions