diff --git a/faststream_gen/__init__.py b/faststream_gen/__init__.py index 429614a..5194f08 100644 --- a/faststream_gen/__init__.py +++ b/faststream_gen/__init__.py @@ -1 +1 @@ -__version__ = "0.1.7rc1" \ No newline at end of file +__version__ = "0.1.7rc2" \ No newline at end of file diff --git a/faststream_gen/_code_generator/app_skeleton_generator.py b/faststream_gen/_code_generator/app_skeleton_generator.py index 9f1e03e..9c46d9d 100644 --- a/faststream_gen/_code_generator/app_skeleton_generator.py +++ b/faststream_gen/_code_generator/app_skeleton_generator.py @@ -1,12 +1,13 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/App_Skeleton_Generator.ipynb. # %% auto 0 -__all__ = ['logger', 'generate_app_skeleton'] +__all__ = ['logger', 'CODE_CONTAINS_IMPLEMENTATION_ERROR', 'generate_app_skeleton'] # %% ../../nbs/App_Skeleton_Generator.ipynb 1 from typing import * import time import json +import ast from pathlib import Path from collections import defaultdict @@ -30,16 +31,43 @@ logger = get_logger(__name__) # %% ../../nbs/App_Skeleton_Generator.ipynb 5 +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( + node: Union[ast.AsyncFunctionDef, ast.FunctionDef] +) -> bool: + return len(node.body) == 2 and isinstance(node.body[-1], ast.Raise) + + +def _check_response_for_implementation(response: str) -> List[str]: + parsed = ast.parse(response) + function_nodes = [ + node + for node in ast.walk(parsed) + if isinstance(node, ast.AsyncFunctionDef) or isinstance(node, ast.FunctionDef) + ] + ret_val = ( + [] + if all(_has_function_implementation(node) for node in function_nodes) + else [CODE_CONTAINS_IMPLEMENTATION_ERROR] + ) + return ret_val + +# %% ../../nbs/App_Skeleton_Generator.ipynb 9 def _validate_response( response: str, output_directory: str, **kwargs: Dict[str, Any] ) -> List[str]: target_file_name = Path(output_directory) / APPLICATION_FILE_PATH write_file_contents(str(target_file_name), response) - ret_val = validate_python_code(str(target_file_name)) - - return ret_val + code_import_errors = validate_python_code(str(target_file_name)) + + if len(code_import_errors) != 0: + return code_import_errors + + return _check_response_for_implementation(response) -# %% ../../nbs/App_Skeleton_Generator.ipynb 8 +# %% ../../nbs/App_Skeleton_Generator.ipynb 15 @retry_on_error() # type: ignore def _generate( model: str, @@ -72,7 +100,7 @@ def _generate( else validator_result ) -# %% ../../nbs/App_Skeleton_Generator.ipynb 11 +# %% ../../nbs/App_Skeleton_Generator.ipynb 18 def generate_app_skeleton( validated_description: str, output_directory: str, diff --git a/faststream_gen/_modidx.py b/faststream_gen/_modidx.py index e1e7819..b1fb3a4 100644 --- a/faststream_gen/_modidx.py +++ b/faststream_gen/_modidx.py @@ -17,8 +17,12 @@ 'faststream_gen/_code_generator/app_and_test_generator.py')}, 'faststream_gen._code_generator.app_description_validator': { 'faststream_gen._code_generator.app_description_validator.validate_app_description': ( 'app_description_validator.html#validate_app_description', 'faststream_gen/_code_generator/app_description_validator.py')}, - 'faststream_gen._code_generator.app_skeleton_generator': { 'faststream_gen._code_generator.app_skeleton_generator._generate': ( 'app_skeleton_generator.html#_generate', + 'faststream_gen._code_generator.app_skeleton_generator': { 'faststream_gen._code_generator.app_skeleton_generator._check_response_for_implementation': ( 'app_skeleton_generator.html#_check_response_for_implementation', + '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', diff --git a/nbs/App_Skeleton_Generator.ipynb b/nbs/App_Skeleton_Generator.ipynb index d01184e..a728f27 100644 --- a/nbs/App_Skeleton_Generator.ipynb +++ b/nbs/App_Skeleton_Generator.ipynb @@ -22,6 +22,7 @@ "from typing import *\n", "import time\n", "import json\n", + "import ast\n", "from pathlib import Path\n", "from collections import defaultdict\n", "\n", @@ -92,6 +93,230 @@ "logger.info(\"ok\")" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "f920f25d", + "metadata": {}, + "outputs": [], + "source": [ + "# | export\n", + "\n", + "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()\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e14893de", + "metadata": {}, + "outputs": [], + "source": [ + "# | export\n", + "\n", + "\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", + "\n", + "\n", + "def _check_response_for_implementation(response: str) -> List[str]:\n", + " parsed = ast.parse(response)\n", + " function_nodes = [\n", + " node\n", + " for node in ast.walk(parsed)\n", + " if isinstance(node, ast.AsyncFunctionDef) or isinstance(node, ast.FunctionDef)\n", + " ]\n", + " ret_val = (\n", + " []\n", + " if all(_has_function_implementation(node) for node in function_nodes)\n", + " else [CODE_CONTAINS_IMPLEMENTATION_ERROR]\n", + " )\n", + " return ret_val" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fad35ae3", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['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()']\n" + ] + } + ], + "source": [ + "fixture = '''\n", + "import asyncio\n", + "import json\n", + "\n", + "import aiohttp\n", + "\n", + "from pydantic import BaseModel, Field, NonNegativeFloat\n", + "\n", + "from faststream import FastStream, Logger\n", + "from faststream.kafka import KafkaBroker\n", + "\n", + "\n", + "class CryptoPrice(BaseModel):\n", + " price: NonNegativeFloat = Field(..., examples=[50000.0], description=\"Current price of cryptocurrency in USD\")\n", + " crypto_currency: str = Field(..., examples=[\"BTC\"], description=\"The cryptocurrency\")\n", + "\n", + "\n", + "broker = KafkaBroker(\"localhost:9092\")\n", + "app = FastStream(broker)\n", + "\n", + "\n", + "async def fetch_crypto_price(url: str) -> dict:\n", + " async with aiohttp.ClientSession() as session:\n", + " async with session.get(url) as response:\n", + " return await response.json()\n", + "\n", + "\n", + "async def get_and_publish_crypto_price(\n", + " crypto_currency: str, logger: Logger, context: ContextRepo, time_interval: int = 2\n", + ") -> None:\n", + " \"\"\"\n", + " While app_is_running variable inside context is True, repeat the following process:\n", + " Retrieve the current cryptocurrency price by sending a GET request to the appropriate URL.\n", + " Extract the price and crypto_currency from the response JSON.\n", + " Create a CryptoPrice object with the retrieved data.\n", + " Publish the CryptoPrice object to the 'new_crypto_price' topic, using the utf-8 encoded crypto_currency as the partition key.\n", + " Asynchronously sleep for the specified time_interval.\n", + " \"\"\"\n", + " raise NotImplementedError()\n", + "\n", + "\n", + "@app.on_startup\n", + "async def app_setup(context: ContextRepo):\n", + " \"\"\"\n", + " Set all necessary global variables inside ContextRepo object:\n", + " Set app_is_running to True - we will use this variable as running loop condition\n", + " \"\"\"\n", + " raise NotImplementedError()\n", + "\n", + "\n", + "@app.on_shutdown\n", + "async def shutdown(context: ContextRepo):\n", + " \"\"\"\n", + " Set all necessary global variables inside ContextRepo object:\n", + " Set app_is_running to False\n", + "\n", + " Get all executed tasks from context and wait for them to finish\n", + " \"\"\"\n", + " raise NotImplementedError()\n", + "\n", + "\n", + "@app.after_startup\n", + "async def publish_crypto_price(logger: Logger, context: ContextRepo):\n", + " \"\"\"\n", + " Create asynchronous tasks for executing get_and_publish_crypto_price function.\n", + " Run this process for Bitcoin and Ethereum.\n", + " Put all executed tasks into a list and set it as a global variable in the context (It is needed so we can wait for these tasks at app shutdown)\n", + " \"\"\"\n", + " raise NotImplementedError()\n", + "'''\n", + "\n", + "actual = _check_response_for_implementation(fixture)\n", + "print(actual)\n", + "assert actual == [CODE_CONTAINS_IMPLEMENTATION_ERROR]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "183899c3", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[]\n" + ] + } + ], + "source": [ + "fixture = '''\n", + "import asyncio\n", + "import json\n", + "\n", + "import aiohttp\n", + "\n", + "from pydantic import BaseModel, Field, NonNegativeFloat\n", + "\n", + "from faststream import ContextRepo, FastStream, Logger\n", + "from faststream.kafka import KafkaBroker\n", + "\n", + "broker = KafkaBroker(\"localhost:9092\")\n", + "app = FastStream(broker)\n", + "\n", + "\n", + "class CryptoPrice(BaseModel):\n", + " price: NonNegativeFloat = Field(\n", + " ..., examples=[50000.0], description=\"Current price of cryptocurrency in USD\"\n", + " )\n", + " crypto_currency: str = Field(\n", + " ..., examples=[\"BTC\"], description=\"The cryptocurrency symbol\"\n", + " )\n", + "\n", + "\n", + "async def fetch_crypto_price(\n", + " url: str, crypto_currency: str, logger: Logger, context: ContextRepo\n", + ") -> None:\n", + " \"\"\"\n", + " Fetches the current cryptocurrency price from the provided URL and publishes it to the 'new_crypto_price' topic.\n", + "\n", + " Instructions:\n", + " 1. Send a GET request to the provided URL.\n", + " 2. Retrieve the current price and cryptocurrency symbol from the response JSON.\n", + " 3. Create a CryptoPrice object with the retrieved data.\n", + " 4. Publish the CryptoPrice object to the 'new_crypto_price' topic, using the crypto_currency as the partition key.\n", + " 5. Sleep for 2 seconds.\n", + " \"\"\"\n", + " raise NotImplementedError()\n", + "\n", + "\n", + "@app.on_startup\n", + "async def app_setup(context: ContextRepo):\n", + " \"\"\"\n", + " Set all necessary global variables inside ContextRepo object:\n", + " Set app_is_running to True - we will use this variable as running loop condition\n", + " \"\"\"\n", + " raise NotImplementedError()\n", + "\n", + "\n", + "@app.on_shutdown\n", + "async def shutdown(context: ContextRepo):\n", + " \"\"\"\n", + " Set all necessary global variables inside ContextRepo object:\n", + " Set app_is_running to False\n", + "\n", + " Get all executed tasks from context and wait them to finish\n", + " \"\"\"\n", + " raise NotImplementedError()\n", + "\n", + "\n", + "@app.after_startup\n", + "async def fetch_crypto_prices(logger: Logger, context: ContextRepo):\n", + " \"\"\"\n", + " Create asynchronous tasks for executing fetch_crypto_price function.\n", + " Run this process for Bitcoin (BTC) and Ethereum (ETH).\n", + " Put all executed tasks to list and set it as global variable in context (It is needed so we can wait for these tasks at app shutdown)\n", + " \"\"\"\n", + " raise NotImplementedError()\n", + "'''\n", + "\n", + "actual = _check_response_for_implementation(fixture)\n", + "print(actual)\n", + "assert actual == []" + ] + }, { "cell_type": "code", "execution_count": null, @@ -107,35 +332,39 @@ ") -> List[str]:\n", " target_file_name = Path(output_directory) / APPLICATION_FILE_PATH\n", " write_file_contents(str(target_file_name), response)\n", - " ret_val = validate_python_code(str(target_file_name))\n", - "\n", - " return ret_val" + " code_import_errors = validate_python_code(str(target_file_name))\n", + " \n", + " if len(code_import_errors) != 0:\n", + " return code_import_errors\n", + " \n", + " return _check_response_for_implementation(response)" ] }, { "cell_type": "code", "execution_count": null, - "id": "15cf8bb2", + "id": "3c6c327c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "[]\n" + "[\"ModuleNotFoundError: No module named 'invalid_module'\"]\n" ] } ], "source": [ "fixture = \"\"\"\n", "import os\n", + "import invalid_module\n", "def say_hello():\n", " print(\"hello\")\n", "\"\"\"\n", "\n", "with TemporaryDirectory() as d:\n", " actual = _validate_response(fixture, d)\n", - " expected = []\n", + " expected = [\"ModuleNotFoundError: No module named 'invalid_module'\"]\n", "\n", " print(actual)\n", " assert actual == expected" @@ -144,28 +373,245 @@ { "cell_type": "code", "execution_count": null, - "id": "3c6c327c", + "id": "15cf8bb2", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "[\"ModuleNotFoundError: No module named 'invalid_module'\"]\n" + "['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()']\n" ] } ], "source": [ + "\n", "fixture = \"\"\"\n", "import os\n", - "import invalid_module\n", "def say_hello():\n", " print(\"hello\")\n", "\"\"\"\n", "\n", "with TemporaryDirectory() as d:\n", " actual = _validate_response(fixture, d)\n", - " expected = [\"ModuleNotFoundError: No module named 'invalid_module'\"]\n", + " expected = [CODE_CONTAINS_IMPLEMENTATION_ERROR]\n", + "\n", + " print(actual)\n", + " assert actual == expected" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a44b6cf2", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[]\n" + ] + } + ], + "source": [ + "fixture = '''\n", + "import os\n", + "def say_hello():\n", + " \"\"\"This is a docstring\"\"\"\n", + " raise NotImplementedError()\n", + "'''\n", + "\n", + "with TemporaryDirectory() as d:\n", + " actual = _validate_response(fixture, d)\n", + " expected = []\n", + "\n", + " print(actual)\n", + " assert actual == expected" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bfb6e984", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[]\n" + ] + } + ], + "source": [ + "fixture = '''\n", + "import asyncio\n", + "import json\n", + "\n", + "import aiohttp\n", + "\n", + "from pydantic import BaseModel, Field, NonNegativeFloat\n", + "\n", + "from faststream import ContextRepo, FastStream, Logger\n", + "from faststream.kafka import KafkaBroker\n", + "\n", + "broker = KafkaBroker(\"localhost:9092\")\n", + "app = FastStream(broker)\n", + "\n", + "\n", + "class CryptoPrice(BaseModel):\n", + " price: NonNegativeFloat = Field(\n", + " ..., examples=[50000.0], description=\"Current price of cryptocurrency in USD\"\n", + " )\n", + " crypto_currency: str = Field(\n", + " ..., examples=[\"BTC\"], description=\"The cryptocurrency symbol\"\n", + " )\n", + "\n", + "\n", + "async def fetch_crypto_price(\n", + " url: str, crypto_currency: str, logger: Logger, context: ContextRepo\n", + ") -> None:\n", + " \"\"\"\n", + " Fetches the current cryptocurrency price from the provided URL and publishes it to the 'new_crypto_price' topic.\n", + "\n", + " Instructions:\n", + " 1. Send a GET request to the provided URL.\n", + " 2. Retrieve the current price and cryptocurrency symbol from the response JSON.\n", + " 3. Create a CryptoPrice object with the retrieved data.\n", + " 4. Publish the CryptoPrice object to the 'new_crypto_price' topic, using the crypto_currency as the partition key.\n", + " 5. Sleep for 2 seconds.\n", + " \"\"\"\n", + " raise NotImplementedError()\n", + "\n", + "\n", + "@app.on_startup\n", + "async def app_setup(context: ContextRepo):\n", + " \"\"\"\n", + " Set all necessary global variables inside ContextRepo object:\n", + " Set app_is_running to True - we will use this variable as running loop condition\n", + " \"\"\"\n", + " raise NotImplementedError()\n", + "\n", + "\n", + "@app.on_shutdown\n", + "async def shutdown(context: ContextRepo):\n", + " \"\"\"\n", + " Set all necessary global variables inside ContextRepo object:\n", + " Set app_is_running to False\n", + "\n", + " Get all executed tasks from context and wait them to finish\n", + " \"\"\"\n", + " raise NotImplementedError()\n", + "\n", + "\n", + "@app.after_startup\n", + "async def fetch_crypto_prices(logger: Logger, context: ContextRepo):\n", + " \"\"\"\n", + " Create asynchronous tasks for executing fetch_crypto_price function.\n", + " Run this process for Bitcoin (BTC) and Ethereum (ETH).\n", + " Put all executed tasks to list and set it as global variable in context (It is needed so we can wait for these tasks at app shutdown)\n", + " \"\"\"\n", + " raise NotImplementedError()\n", + "'''\n", + "\n", + "with TemporaryDirectory() as d:\n", + " actual = _validate_response(fixture, d)\n", + " expected = []\n", + "\n", + " print(actual)\n", + " assert actual == expected" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2c1ac70a", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['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()']\n" + ] + } + ], + "source": [ + "fixture = '''\n", + "import asyncio\n", + "import json\n", + "\n", + "import aiohttp\n", + "\n", + "from pydantic import BaseModel, Field, NonNegativeFloat\n", + "\n", + "from faststream import ContextRepo, FastStream, Logger\n", + "from faststream.kafka import KafkaBroker\n", + "\n", + "broker = KafkaBroker(\"localhost:9092\")\n", + "app = FastStream(broker)\n", + "\n", + "\n", + "class CryptoPrice(BaseModel):\n", + " price: NonNegativeFloat = Field(..., examples=[50000.0], description=\"Current price of cryptocurrency in USD\")\n", + " crypto_currency: str = Field(..., examples=[\"BTC\"], description=\"The cryptocurrency\")\n", + "\n", + "\n", + "async def fetch_crypto_price(url: str) -> dict:\n", + " async with aiohttp.ClientSession() as session:\n", + " async with session.get(url) as response:\n", + " return await response.json()\n", + "\n", + "\n", + "async def get_crypto_price(crypto_currency: str) -> CryptoPrice:\n", + " url = f\"https://api.coinbase.com/v2/prices/{crypto_currency}-USD/spot\"\n", + " response = await fetch_crypto_price(url)\n", + " price = response[\"data\"][\"amount\"]\n", + " return CryptoPrice(price=price, crypto_currency=crypto_currency)\n", + "\n", + "\n", + "@app.on_startup\n", + "async def app_setup(context: ContextRepo):\n", + " context.crypto_currencies = [\"BTC\", \"ETH\"]\n", + "\n", + "\n", + "@app.on_shutdown\n", + "async def shutdown(context: ContextRepo):\n", + " context.app_is_running = False\n", + " await asyncio.gather(*context.tasks)\n", + "\n", + "\n", + "async def fetch_and_publish_crypto_price(\n", + " crypto_currency: str, logger: Logger, context: ContextRepo, interval: int = 2\n", + ") -> None:\n", + " while context.app_is_running:\n", + " crypto_price = await get_crypto_price(crypto_currency)\n", + " await broker.publish(\n", + " topic=\"new_crypto_price\",\n", + " key=crypto_currency.encode(\"utf-8\"),\n", + " value=crypto_price.json().encode(\"utf-8\"),\n", + " )\n", + " await asyncio.sleep(interval)\n", + "\n", + "\n", + "@app.after_startup\n", + "async def publish_crypto_price(logger: Logger, context: ContextRepo):\n", + " context.tasks = []\n", + " for crypto_currency in context.crypto_currencies:\n", + " task = asyncio.create_task(\n", + " fetch_and_publish_crypto_price(crypto_currency, logger, context)\n", + " )\n", + " context.tasks.append(task)\n", + "\n", + "\n", + "if __name__ == \"__main__\":\n", + " asyncio.run(app.run())\n", + "'''\n", + "\n", + "with TemporaryDirectory() as d:\n", + " actual = _validate_response(fixture, d)\n", + " expected = [CODE_CONTAINS_IMPLEMENTATION_ERROR]\n", "\n", " print(actual)\n", " assert actual == expected" @@ -245,6 +691,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -269,7 +730,6 @@ "==== YOUR RESPONSE ====\n", "\n", "some valid skeleton code\n", - "is_valid_skeleton_code=True\n", "OK\n" ] } @@ -325,6 +785,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -371,6 +846,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -433,6 +923,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -512,6 +1017,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -534,7 +1054,13 @@ "Message:\n", "some invalid app description\n", "==== YOUR RESPONSE ====\n", - "\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ "[INFO] faststream_gen._code_generator.chat: Validation failed, trying again...Errors:\n", "SyntaxError: '(' was never closed (application.py, line 2)\n", "[INFO] faststream_gen._code_generator.chat: \n", @@ -558,6 +1084,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -620,6 +1161,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -674,13 +1230,7 @@ "\n", "SyntaxError: '(' was never closed (application.py, line 2)\n", "==== YOUR RESPONSE ====\n", - "\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ + "\n", "[INFO] faststream_gen._code_generator.chat: Validation failed, trying again...Errors:\n", "SyntaxError: '(' was never closed (application.py, line 2)\n", "[INFO] faststream_gen._code_generator.helper: Attempt 1 failed. Restarting step.\n", @@ -705,6 +1255,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -751,6 +1316,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -789,7 +1369,13 @@ "\n", "SyntaxError: '(' was never closed (application.py, line 2)\n", "==== YOUR RESPONSE ====\n", - "\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ "[INFO] faststream_gen._code_generator.chat: Validation failed, trying again...Errors:\n", "SyntaxError: '(' was never closed (application.py, line 2)\n", "[INFO] faststream_gen._code_generator.chat: \n", @@ -813,6 +1399,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -979,6 +1580,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -1099,6 +1715,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -1170,6 +1801,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -1255,6 +1901,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -1330,16 +1991,16 @@ "\n", "SyntaxError: invalid syntax (application.py, line 1)\n", "==== YOUR RESPONSE ====\n", - "\n", - "[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 0 failed. Restarting step.\n" + "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ + "[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 0 failed. Restarting step.\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", @@ -1361,6 +2022,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -1432,6 +2108,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -1517,6 +2208,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -1592,16 +2298,16 @@ "\n", "SyntaxError: invalid syntax (application.py, line 1)\n", "==== YOUR RESPONSE ====\n", - "\n", - "[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" + "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ + "[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", "\n", "Prompt to the model: \n", @@ -1623,6 +2329,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -1694,6 +2415,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -1779,6 +2515,21 @@ "\n", "In such cases, it is necessary to add the \"import asyncio\" statement at the top of the code. \n", "\n", + "3. Whenever you are creating a message class while generating Faststream skeleton and the application code, make sure the message class is a derived class of BaseModel from pydantic.\n", + "\n", + " Example of a Valid message class:\n", + " class Pet(BaseModel):\n", + " pet_id: NonNegativeInt = Field(..., examples=[1], description=\"Int data example\")\n", + " species: str = Field(..., examples=[\"dog\"], description=\"Pet example\")\n", + "\n", + " Example of a invalid message class:\n", + " class Pet:\n", + " def __init__(self, pet_id: int, species: str):\n", + " self.pet_id = pet_id\n", + " self.species = species\n", + " \n", + "4. When generating a lists of external dependencies from both the ==== APP CODE ==== and ==== TEST CODE ==== sections, include only external libraries and not internal Python libraries like json, time, asyncio, etc., in the ==== APP REQUIREMENT ==== or ==== TEST REQUIREMENT ==== sections. Additionally do not include pytest in the ==== TEST REQUIREMENT ====\n", + "\n", "You will encounter sections marked as:\n", "\n", "==== APP DESCRIPTION: ====\n", @@ -1854,19 +2605,16 @@ "\n", "SyntaxError: invalid syntax (application.py, line 1)\n", "==== YOUR RESPONSE ====\n", - "\n", - "[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" + "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ - "⠧ Generating FastStream app skeleton code (usually takes around 15 to 45 seconds)... ************************************************************************************************************************\n", - "is_valid_skeleton_code=False\n", - "total_usage=[defaultdict(, {'prompt_tokens': 387, 'completion_tokens': 3, 'total_tokens': 390}), defaultdict(, {'prompt_tokens': 387, 'completion_tokens': 3, 'total_tokens': 390}), defaultdict(, {'prompt_tokens': 387, 'completion_tokens': 3, 'total_tokens': 390})]\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", "False\n" ] diff --git a/settings.ini b/settings.ini index 7b5404d..4799625 100644 --- a/settings.ini +++ b/settings.ini @@ -5,7 +5,7 @@ ### Python library ### repo = faststream-gen lib_name = %(repo)s -version = 0.1.7rc1 +version = 0.1.7rc2 min_python = 3.8 license = apache2 black_formatting = False