the cat knows how to collect the data you need in a conversational way!
class PizzaOrder(CBaseModel):
pizza_type: str = Field(description="...", default="...")
address: str = Field(description="...")
phone: str = Field(description="...")
#...
# Implement execute action overriding method
def execute_action(self, cat):
# execute action
return # action output
# Implement examples method
def examples(self, cat):
return [
{
"user_message": "My phone is: 123123123",
"model_before": "{\"pizza_type\":\"Diavola\"}",
"model_after": "{\"pizza_type\":\"Diavola\",\"phone\":\"123123123\"}",
"validation": "ask_for: address; error: none",
"response": "Could you give me your delivery address?"
},
#...
]
@tool(return_direct=True)
def intent_start(input, cat):
''' <docString> '''
return PizzaOrder.start(cat)
@tool
def intent_stop(input, cat):
''' <docString> '''
return PizzaOrder.stop(cat)
@hook
def agent_fast_reply(fast_reply: Dict, cat) -> Dict:
return PizzaOrder.dialogue_action(fast_reply, cat)
@hook
def agent_prompt_prefix(prefix, cat) -> str:
return PizzaOrder.dialogue_prefix(prefix, cat)
# Extend CForm class
class MyForm(CForm):
def __init__(self, model_class, key, cat):
print("MyForm constructor")
super().__init__(model_class, key, cat)
def check_user_confirm(self) -> bool:
print("MyForm check_user_confirm")
return super().check_user_confirm()
def user_message_to_json(self):
print("MyForm user_message_to_json")
return super().user_message_to_json()
def model_merge(self, json_details):
print("MyForm model_merge")
return super().model_merge(json_details)
def model_validate(self, model):
print("MyForm model_validate")
return super().model_validate(model)
#...
@tool(return_direct=True)
def intent_start(input, cat):
''' <docString> '''
return PizzaOrder.start(cat, form=MyForm)