diff --git a/faststream_gen/_code_generator/app_skeleton_generator.py b/faststream_gen/_code_generator/app_skeleton_generator.py index 1afab83..9c46d9d 100644 --- a/faststream_gen/_code_generator/app_skeleton_generator.py +++ b/faststream_gen/_code_generator/app_skeleton_generator.py @@ -1,7 +1,7 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/App_Skeleton_Generator.ipynb. # %% auto 0 -__all__ = ['logger', 'CODE_CONTAINS_IMPLEMENTATION_ERROR', 'has_function_implementation', 'generate_app_skeleton'] +__all__ = ['logger', 'CODE_CONTAINS_IMPLEMENTATION_ERROR', 'generate_app_skeleton'] # %% ../../nbs/App_Skeleton_Generator.ipynb 1 from typing import * @@ -34,7 +34,7 @@ CODE_CONTAINS_IMPLEMENTATION_ERROR = "Error: The response contains code implementation. Rewrite the skeleton code without implementing the business logic for the functions. Ensure the new code has only google styled docstring describing the business logic step by step and raise NotImplementedError()" # %% ../../nbs/App_Skeleton_Generator.ipynb 6 -def has_function_implementation( +def _has_function_implementation( node: Union[ast.AsyncFunctionDef, ast.FunctionDef] ) -> bool: return len(node.body) == 2 and isinstance(node.body[-1], ast.Raise) @@ -49,7 +49,7 @@ def _check_response_for_implementation(response: str) -> List[str]: ] ret_val = ( [] - if all(has_function_implementation(node) for node in function_nodes) + if all(_has_function_implementation(node) for node in function_nodes) else [CODE_CONTAINS_IMPLEMENTATION_ERROR] ) return ret_val diff --git a/faststream_gen/_modidx.py b/faststream_gen/_modidx.py index e10f81d..b1fb3a4 100644 --- a/faststream_gen/_modidx.py +++ b/faststream_gen/_modidx.py @@ -21,12 +21,12 @@ 'faststream_gen/_code_generator/app_skeleton_generator.py'), 'faststream_gen._code_generator.app_skeleton_generator._generate': ( 'app_skeleton_generator.html#_generate', 'faststream_gen/_code_generator/app_skeleton_generator.py'), + 'faststream_gen._code_generator.app_skeleton_generator._has_function_implementation': ( 'app_skeleton_generator.html#_has_function_implementation', + 'faststream_gen/_code_generator/app_skeleton_generator.py'), 'faststream_gen._code_generator.app_skeleton_generator._validate_response': ( 'app_skeleton_generator.html#_validate_response', 'faststream_gen/_code_generator/app_skeleton_generator.py'), 'faststream_gen._code_generator.app_skeleton_generator.generate_app_skeleton': ( 'app_skeleton_generator.html#generate_app_skeleton', - 'faststream_gen/_code_generator/app_skeleton_generator.py'), - 'faststream_gen._code_generator.app_skeleton_generator.has_function_implementation': ( 'app_skeleton_generator.html#has_function_implementation', - 'faststream_gen/_code_generator/app_skeleton_generator.py')}, + 'faststream_gen/_code_generator/app_skeleton_generator.py')}, 'faststream_gen._code_generator.chat': { 'faststream_gen._code_generator.chat.CustomAIChat': ( 'chat.html#customaichat', 'faststream_gen/_code_generator/chat.py'), 'faststream_gen._code_generator.chat.CustomAIChat.__call__': ( 'chat.html#customaichat.__call__', diff --git a/nbs/App_Skeleton_Generator.ipynb b/nbs/App_Skeleton_Generator.ipynb index dc69f7a..a728f27 100644 --- a/nbs/App_Skeleton_Generator.ipynb +++ b/nbs/App_Skeleton_Generator.ipynb @@ -115,7 +115,7 @@ "# | export\n", "\n", "\n", - "def has_function_implementation(\n", + "def _has_function_implementation(\n", " node: Union[ast.AsyncFunctionDef, ast.FunctionDef]\n", ") -> bool:\n", " return len(node.body) == 2 and isinstance(node.body[-1], ast.Raise)\n", @@ -130,7 +130,7 @@ " ]\n", " ret_val = (\n", " []\n", - " if all(has_function_implementation(node) for node in function_nodes)\n", + " if all(_has_function_implementation(node) for node in function_nodes)\n", " else [CODE_CONTAINS_IMPLEMENTATION_ERROR]\n", " )\n", " return ret_val" @@ -2308,7 +2308,7 @@ "[INFO] faststream_gen._code_generator.chat: Validation failed, trying again...Errors:\n", "SyntaxError: invalid syntax (application.py, line 1)\n", "[INFO] faststream_gen._code_generator.helper: Attempt 1 failed. Restarting step.\n", - "⠴ Generating FastStream app skeleton code (usually takes around 15 to 45 seconds)... [INFO] faststream_gen._code_generator.chat: \n", + "⠼ Generating FastStream app skeleton code (usually takes around 15 to 45 seconds)... [INFO] faststream_gen._code_generator.chat: \n", "\n", "Prompt to the model: \n", "\n", @@ -2612,7 +2612,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "[INFO] faststream_gen._code_generator.chat: Validation failed, trying again...Errors:\n", + "⠴ Generating FastStream app skeleton code (usually takes around 15 to 45 seconds)... [INFO] faststream_gen._code_generator.chat: Validation failed, trying again...Errors:\n", "SyntaxError: invalid syntax (application.py, line 1)\n", "[INFO] faststream_gen._code_generator.helper: Attempt 2 failed. Restarting step.\n", " ✘ Error: Failed to generate a valid application skeleton code. \n",