validators¶
About¶
Key to glyphdeck is the Pydantic validation model that is passed to the LLMHandler to direct its output.
Access¶
gd.validators.ModelName
Usage¶
cascade.set_llm_handler(
provider="OpenAI",
model="gpt-4o-mini",
system_message=(
"You are an expert pizza shop customer feedback analyst system."
"Analyse the feedback and return results in the correct format."
),
validation_model=gd.validators.SubCatsSentiment,
cache_identifier="pizzshop_sentiment",
)
Built-in¶
For a given text input the LLM will be instructed to return the:
.Sentiment - sentiment score (-1.00 to 1.00)
.PrimaryCat - primary category
.Top5Cats - top 5 categories
.SubCats - sub-categories
.PrimaryCatSentiment - primary category and sentiment score
.PrimarySubCat - primary category and sub-categories
.SubCatsSentiment - sub-categories and sentiment score
.SubCatsPerItemSentiment - sub-categories with sentiment per item
.SubCatsPerItemOverallSentiment - sub-categories with sentiment score per item and the overall sentiment score
.TopCatsSentiment - top categories and sentiment score
.CatHierarchySentiment - full hierarchy of categories and the overall sentiment score
Custom Validators¶
Any valid Pydantic BaseModel can be used for validation. You can also inherit from .BaseValidatorModel to make use of the logic used in the built-in validators.
Refer to the Pydantic documentation for more info.