@@ -1682,7 +1682,20 @@ def convert_to_model(
16821682 agent_name : str = "gpt4free" ,
16831683 max_failures : int = 3 ,
16841684 response_type : str = None ,
1685+ ** kwargs ,
16851686 ):
1687+ """
1688+ Converts a string to a Pydantic model using an AGiXT agent.
1689+
1690+ Args:
1691+
1692+ input_string (str): The string to convert to a model.
1693+ model (Type[BaseModel]): The Pydantic model to convert the string to.
1694+ agent_name (str): The name of the AGiXT agent to use for the conversion.
1695+ max_failures (int): The maximum number of times to retry the conversion if it fails.
1696+ response_type (str): The type of response to return. Either 'json' or None. None will return the model.
1697+ **kwargs: Additional arguments to pass to the AGiXT agent as prompt arguments.
1698+ """
16861699 input_string = str (input_string )
16871700 fields = model .__annotations__
16881701 field_descriptions = []
@@ -1695,12 +1708,17 @@ def convert_to_model(
16951708 description += f" (Enum values: { enum_values } )"
16961709 field_descriptions .append (description )
16971710 schema = "\n " .join (field_descriptions )
1711+ if "user_input" in kwargs :
1712+ del kwargs ["user_input" ]
1713+ if "schema" in kwargs :
1714+ del kwargs ["schema" ]
16981715 response = self .prompt_agent (
16991716 agent_name = agent_name ,
1700- prompt_name = "Convert to Pydantic Model" ,
1717+ prompt_name = "Convert to Model" ,
17011718 prompt_args = {
17021719 "schema" : schema ,
17031720 "user_input" : input_string ,
1721+ ** kwargs ,
17041722 },
17051723 )
17061724 if "```json" in response :
@@ -1735,6 +1753,7 @@ def convert_to_model(
17351753 model = model ,
17361754 agent_name = agent_name ,
17371755 max_failures = max_failures ,
1756+ ** kwargs ,
17381757 )
17391758
17401759 def convert_list_of_dicts (
0 commit comments