diff --git a/promptify/parser/parser.py b/promptify/parser/parser.py index 2af9c91..83417a2 100644 --- a/promptify/parser/parser.py +++ b/promptify/parser/parser.py @@ -162,7 +162,7 @@ def complete_json_object(self, json_str: str, completion_str: str) -> Any: return python_obj def get_possible_completions( - self, json_str: str, max_completion_length: int = 5 + self, json_str: str, json_depth_limit: int = 5 ) -> Union[Dict[str, Any], List[Any]]: """ Returns a list of possible completions for a JSON object string. @@ -171,7 +171,7 @@ def get_possible_completions( ---------- json_str : str The JSON object string - max_completion_length : int, optional + json_depth_limit : int, optional The maximum length of the completion strings to try (default is 5) Returns @@ -190,7 +190,7 @@ def get_possible_completions( should_end_mark = "]" if json_str.strip()[0] == "[" else "}" completions = [] for completion_str in self.get_combinations( - candidate_marks, max_completion_length, should_end_mark=should_end_mark + candidate_marks, json_depth_limit, should_end_mark=should_end_mark ): try: completed_obj = self.complete_json_object(json_str, completion_str) @@ -199,7 +199,7 @@ def get_possible_completions( pass return self.find_max_length(completions) - def fit(self, json_str: str, max_completion_length: int = 5) -> Dict[str, Any]: + def fit(self, json_str: str, json_depth_limit: int = 5) -> Dict[str, Any]: """ Tries to parse the input JSON string and complete it if it is incomplete. @@ -207,7 +207,7 @@ def fit(self, json_str: str, max_completion_length: int = 5) -> Dict[str, Any]: ---------- json_str : str The input JSON string - max_completion_length : int, optional + json_depth_limit : int, optional The maximum length of the completion strings to try (default is 5) Returns @@ -230,7 +230,7 @@ def fit(self, json_str: str, max_completion_length: int = 5) -> Dict[str, Any]: json_str = re.sub(r"[\[\]\{\}\s]+$", "", json_str) try: output = self.get_possible_completions( - json_str, max_completion_length=max_completion_length + json_str, json_depth_limit=json_depth_limit ) return { "status": "completed",