diff --git a/nbs/Coversation_Workflow.ipynb b/nbs/Coversation_Workflow.ipynb index 87d9898..e4d43d8 100644 --- a/nbs/Coversation_Workflow.ipynb +++ b/nbs/Coversation_Workflow.ipynb @@ -24,7 +24,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 8, "id": "fd5da16b", "metadata": {}, "outputs": [], @@ -59,18 +59,33 @@ "You are a product owner which works with streaming application projects (using Kafka) and all the applications are using python FastStream framework.\n", "You are in a chat with the client and team leader to discuss the requirements for the new application that needs to be implemented.\n", "Go through the given application description, and check if everything what you think is necessary is defined.\n", + "The goal of this conversation is to create tehnical design document.\n", "\n", + "This conversation will be finished in one of the following cases:\n", + " 1. the tehnical design document is created by \"create_brief\" or \"continue_create_brief\" function and you aprove it\n", + " You should NOT write tehnical design document by yourself\n", + " \n", + " 2. The requests does not confirm with legal and ethical standards\n", + " \n", "Your response should always be ONE of the following: \n", "1. If you have a question for the user or team leader please ask it. Please ask ONE QUESTION at time.\n", - "2. Before you create a description needed for writing a technical brief by calling the \"create_brief\", please list all assumptions and information and then verify with the user that you understanding is correct.\n", "\n", - "Suggest calling \"create_brief\" function when everything is clear to you have no more questions.\n", + "2. Before you create a description needed for writing a technical design document by calling the \"create_brief\", \n", + "please list all assumptions and information and then verify with the user that you understanding is correct.\n", + "\n", + "3. Suggest calling \"create_brief\" function when everything is clear to you have no more questions.\n", + "\"create_brief\" function can only be suggested and called ONCE in the whole conversation.\n", + "If you need to continue creating tehnical brief after receiving additional questions, please use \"continue_create_brief\" function ONLY.\n", "\n", - "If \"create_bried\" returns with additional questions, please include the additional answers and clarifications in a new suggestion for calling the \"create_brief\" again.\n", + "4. If \"create_brief\" or \"continue_create_brief\" returns with additional questions, \n", + "please include the additional answers and clarifications in a new suggestion for calling the \"continue_create_brief\".\n", "\n", - "Once the \"create_brief\" function returns the technical brief, check if it correct and in line with the user requests. If you notice any discrepancies,\n", - "please raise you concerns immediately and suggest calling the \"create_brief\" again with more elaborate instructions.\n", + "5. Once the \"create_brief\" or \"continue_create_brief\" function returns the technical brief, check if it correct and in line with the user requests. If you notice any discrepancies,\n", + "please raise you concerns immediately and suggest calling the \"continue_create_brief\" with more elaborate instructions.\n", "\n", + "6. At each step you should verify that user requirements conform with legal and ethical standards. \n", + "If not, raise your concerns to the user and ask for additional clarifications before proceeding. \n", + "If you are not satisfied with additional clarifications respond with \"TERMINATE\".\n", "\"\"\"\n", "# " ] @@ -84,7 +99,7 @@ "source": [ "create_brief = {\n", " \"name\": \"create_brief\",\n", - " \"description\": \"Create brief from global variable\",\n", + " \"description\": \"Create tehnical design document\",\n", " \"parameters\": {\n", " \"type\": \"object\",\n", " \"properties\": {\n", @@ -97,12 +112,26 @@ " }\n", " }\n", "\n", + "continue_create_brief = {\n", + " \"name\": \"continue_create_brief\",\n", + " \"description\": \"Continue conversation for creating tehnical design document\",\n", + " \"parameters\": {\n", + " \"type\": \"object\",\n", + " \"properties\": {\n", + " \"answer\": {\n", + " \"type\": \"string\",\n", + " \"description\": \"Answer to the last question asked\", },\n", + " },\n", + " \"required\": [\"answer\"],\n", + " }\n", + " }\n", + "\n", "\n", "llm_config_product_owner = {\n", " \"config_list\": config_list,\n", " \"seed\": 42,\n", " \"temperature\": 0.7, # temperature for sampling\n", - " \"functions\": [create_brief],\n", + " \"functions\": [create_brief, continue_create_brief],\n", "} \n", "\n", "# user_proxy = autogen.UserProxyAgent(\n", @@ -110,6 +139,13 @@ "# system_message=\"A human admin.\",\n", "# human_input_mode=\"AUTO\"\n", "# )\n", + "\n", + "llm_config = {\n", + " \"config_list\": config_list,\n", + " \"seed\": 42,\n", + " \"temperature\": 0.7, # temperature for sampling\n", + "} \n", + "\n", "user_proxy = autogen.AssistantAgent(\n", " name=\"User_proxy\",\n", " system_message=\"\"\"A non-technical user wishing to outsource software development work to a software agency.\n", @@ -122,7 +158,7 @@ "\n", "You will terminate the discussion by outputing the word TERMINATE once you are satisfied with the output.\n", "\"\"\",\n", - " llm_config=llm_config_product_owner,\n", + " llm_config=llm_config,\n", ")\n", "\n", "product_owner = autogen.AssistantAgent(\n", @@ -132,6 +168,14 @@ ")" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "52743c61", + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": 5, @@ -139,12 +183,23 @@ "metadata": {}, "outputs": [], "source": [ - "called_already: bool = False\n", + "called_counter: int = -1\n", "def create_brief(desc: str):\n", " print(f\"create_brief({desc=})\")\n", - " global called_already\n", - " if called_already:\n", - " return \"\"\"\n", + " global called_counter\n", + " \n", + " called_counter += 1\n", + " \n", + " if called_counter == 0:\n", + " return \"Which specific API service will we be using to fetch the cryptocurrency prices? Is it CoinMarketCap, CryptoCompare, or some other service?\"\n", + " \n", + " elif called_counter == 1:\n", + " return \"Is Authentication/Authorisation required?\"\n", + " \n", + " else:\n", + " api_used = \"CryptoCompare\" if called_counter == 2 else \"Coinbase\"\n", + " \n", + " return f\"\"\"\n", " Create a FastStream application which will retrieve the current cryptocurrency price\n", " and publish it to new_crypto_price topic. \n", "\n", @@ -157,22 +212,16 @@ " Use utf-8 encoded crypto_currency attribute as a partition key when publishing\n", " the message to new_crypto_price topic.\n", "\n", - " To retrieve the prices, use the CryptoCompare API.\n", + " To retrieve the prices, use the {api_used} API.\n", " Retrieve only Bitcoin and ETH prices.\n", "\"\"\"\n", - " called_already = True\n", " \n", - " return \"I am not clear on what API should I use for retrieving crypto prises. I recommend Coinbase API, is it fine with you?\"\n", + " \n", " \n", - "\n", - "# function_executer_proxy = autogen.UserProxyAgent(\n", - "# name=\"function_executer_proxy\",\n", - "# human_input_mode=\"NEVER\",\n", - "# max_consecutive_auto_reply=10,\n", - "# # is_termination_msg=lambda x: \"content\" in x and x[\"content\"] is not None and x[\"content\"].rstrip().endswith(\"TERMINATE\"),\n", - "# code_execution_config={\"work_dir\": \"planning\"},\n", - "# function_map={\"create_brief\": create_brief},\n", - "# )" + " \n", + "def continue_create_brief(answer: str):\n", + " print(f\"continue_create_brief({answer=})\")\n", + " return create_brief(answer)\n" ] }, { @@ -187,7 +236,8 @@ " # system_message=\"A human admin.\",\n", " human_input_mode=\"NEVER\",\n", " code_execution_config={\"work_dir\": \"planning\"},\n", - " function_map={\"create_brief\": create_brief},\n", + " function_map={\"create_brief\": create_brief, \"continue_create_brief\": continue_create_brief},\n", + " # is_termination_msg=lambda x: \"content\" in x and x[\"content\"] is not None and x[\"content\"].rstrip().endswith(\"TERMINATE\"),\n", ")" ] }, @@ -213,38 +263,35 @@ "- price: non-negative float (current price of cryptocurrency in USD)\n", "- crypto_currency: string (the cryptocurrency e.g. BTC, ETH...)\n", "\n", + "\n", "Use utf-8 encoded crypto_currency attribute as a partition key when publishing\n", "the message to new_crypto_price topic.\n", "\n", "\n", - "\n", "Is everything clear with the above description?\n", "\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mProduct_owner\u001b[0m (to chat_manager):\n", "\n", - "I have a few questions to clarify the requirements further:\n", - "\n", - "1. From which source or API should the application retrieve the cryptocurrency price?\n", - "2. Should the application support multiple cryptocurrencies or only one specific cryptocurrency?\n", + "Do we have a specific source or API from where the application should retrieve the cryptocurrency prices?\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mUser_proxy\u001b[0m (to chat_manager):\n", "\n", - "1. The source or API will be left to the technical team to decide.\n", - "2. The application should support only Bitcoin and Ethereum.\n", + "That's a technical decision. I leave it to you.\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mProduct_owner\u001b[0m (to chat_manager):\n", "\n", - "Thank you for the clarification. Here is my understanding based on your inputs:\n", + "Let's clarify the requirements for the new application:\n", "\n", - "1. We will create a FastStream application that fetches the current cryptocurrency prices from an API, which will be decided by our technical team.\n", - "2. The application will specifically target Bitcoin and Ethereum.\n", - "3. The fetched data will be published to a new_crypto_price topic every 2 seconds.\n", - "4. The published message will be in JSON format containing two attributes: price (non-negative float representing the current price in USD) and crypto_currency (string representing the type of cryptocurrency).\n", - "5. The application will use the utf-8 encoded crypto_currency attribute as a partition key when publishing the message to the new_crypto_price topic.\n", + "1. The application will be built using the FastStream framework.\n", + "2. It will retrieve current cryptocurrency prices from a source that the team will determine.\n", + "3. The data retrieval will occur every 2 seconds.\n", + "4. The application will publish the data to the 'new_crypto_price' Kafka topic.\n", + "5. The published message will be a JSON with two attributes: 'price' and 'crypto_currency'. The 'price' will be a non-negative float representing the current price of the cryptocurrency in USD. The 'crypto_currency' will be a string representing the type of cryptocurrency (e.g., BTC, ETH).\n", + "6. The 'crypto_currency' attribute will be used as a partition key when publishing the message to 'new_crypto_price' topic. This attribute will be utf-8 encoded.\n", "\n", "Is my understanding correct?\n", "\n", @@ -253,6 +300,30 @@ "\n", "Yes.\n", "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mProduct_owner\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Suggested function Call: create_brief *****\u001b[0m\n", + "Arguments: \n", + "{\n", + "\"desc\": \"The application will be built using the FastStream framework and it will retrieve current cryptocurrency prices from a source that the team will determine. The data retrieval will occur every 2 seconds. The application will publish the data to the 'new_crypto_price' Kafka topic. The published message will be a JSON with two attributes: 'price' and 'crypto_currency'. The 'price' will be a non-negative float representing the current price of the cryptocurrency in USD. The 'crypto_currency' will be a string representing the type of cryptocurrency (e.g., BTC, ETH). The 'crypto_currency' attribute will be used as a partition key when publishing the message to 'new_crypto_price' topic. This attribute will be utf-8 encoded.\"\n", + "}\n", + "\u001b[32m*************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[35m\n", + ">>>>>>>> EXECUTING FUNCTION create_brief...\u001b[0m\n", + "create_brief(desc=\"The application will be built using the FastStream framework and it will retrieve current cryptocurrency prices from a source that the team will determine. The data retrieval will occur every 2 seconds. The application will publish the data to the 'new_crypto_price' Kafka topic. The published message will be a JSON with two attributes: 'price' and 'crypto_currency'. The 'price' will be a non-negative float representing the current price of the cryptocurrency in USD. The 'crypto_currency' will be a string representing the type of cryptocurrency (e.g., BTC, ETH). The 'crypto_currency' attribute will be used as a partition key when publishing the message to 'new_crypto_price' topic. This attribute will be utf-8 encoded.\")\n", + "\u001b[33mFunction_executor_proxy\u001b[0m (to chat_manager):\n", + "\n", + "\u001b[32m***** Response from calling function \"create_brief\" *****\u001b[0m\n", + "Which specific API service will we be using to fetch the cryptocurrency prices? Is it CoinMarketCap, CryptoCompare, or some other service?\n", + "\u001b[32m*********************************************************\u001b[0m\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mProduct_owner\u001b[0m (to chat_manager):\n", + "\n", + "The client has left the choice of the API for retrieving cryptocurrency prices to our discretion. We should choose the one that best suits our needs and requirements.\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mFunction_executor_proxy\u001b[0m (to chat_manager):\n", @@ -262,45 +333,47 @@ "--------------------------------------------------------------------------------\n", "\u001b[33mProduct_owner\u001b[0m (to chat_manager):\n", "\n", - "\u001b[32m***** Suggested function Call: create_brief *****\u001b[0m\n", + "\u001b[32m***** Suggested function Call: continue_create_brief *****\u001b[0m\n", "Arguments: \n", "{\n", - " \"desc\": \"We need to create a FastStream application that fetches the current prices for Bitcoin and Ethereum from an API, which will be decided by our technical team. The application will publish this data to a new_crypto_price topic every 2 seconds. The published message will be in JSON format and will contain two attributes: price (a non-negative float representing the current price in USD) and crypto_currency (a string representing the type of cryptocurrency, i.e., BTC or ETH). The application will use the utf-8 encoded crypto_currency attribute as a partition key when publishing the message to the new_crypto_price topic.\"\n", + "\"answer\": \"The client has left the choice of the API for retrieving cryptocurrency prices to our discretion. We should choose the one that best suits our needs and requirements.\"\n", "}\n", - "\u001b[32m*************************************************\u001b[0m\n", + "\u001b[32m**********************************************************\u001b[0m\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[35m\n", - ">>>>>>>> EXECUTING FUNCTION create_brief...\u001b[0m\n", - "create_brief(desc='We need to create a FastStream application that fetches the current prices for Bitcoin and Ethereum from an API, which will be decided by our technical team. The application will publish this data to a new_crypto_price topic every 2 seconds. The published message will be in JSON format and will contain two attributes: price (a non-negative float representing the current price in USD) and crypto_currency (a string representing the type of cryptocurrency, i.e., BTC or ETH). The application will use the utf-8 encoded crypto_currency attribute as a partition key when publishing the message to the new_crypto_price topic.')\n", + ">>>>>>>> EXECUTING FUNCTION continue_create_brief...\u001b[0m\n", + "continue_create_brief(answer='The client has left the choice of the API for retrieving cryptocurrency prices to our discretion. We should choose the one that best suits our needs and requirements.')\n", + "create_brief(desc='The client has left the choice of the API for retrieving cryptocurrency prices to our discretion. We should choose the one that best suits our needs and requirements.')\n", "\u001b[33mFunction_executor_proxy\u001b[0m (to chat_manager):\n", "\n", - "\u001b[32m***** Response from calling function \"create_brief\" *****\u001b[0m\n", - "I am not clear on what API should I use for retrieving crypto prises. I recommend Coinbase API, is it fine with you?\n", - "\u001b[32m*********************************************************\u001b[0m\n", + "\u001b[32m***** Response from calling function \"continue_create_brief\" *****\u001b[0m\n", + "Is Authentication/Authorisation required?\n", + "\u001b[32m******************************************************************\u001b[0m\n", "\n", "--------------------------------------------------------------------------------\n", - "\u001b[33mUser_proxy\u001b[0m (to chat_manager):\n", + "\u001b[33mProduct_owner\u001b[0m (to chat_manager):\n", "\n", - "Yes.\n", + "The authentication/authorization requirement will depend on the API service that we choose for fetching the cryptocurrency prices. Some APIs might require it, while others might not. We will ensure to handle this aspect appropriately during the development phase.\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mProduct_owner\u001b[0m (to chat_manager):\n", "\n", - "\u001b[32m***** Suggested function Call: create_brief *****\u001b[0m\n", + "\u001b[32m***** Suggested function Call: continue_create_brief *****\u001b[0m\n", "Arguments: \n", "{\n", - " \"desc\": \"We need to create a FastStream application that fetches the current prices for Bitcoin and Ethereum from the Coinbase API. The application will publish this data to a new_crypto_price topic every 2 seconds. The published message will be in JSON format and will contain two attributes: price (a non-negative float representing the current price in USD) and crypto_currency (a string representing the type of cryptocurrency, i.e., BTC or ETH). The application will use the utf-8 encoded crypto_currency attribute as a partition key when publishing the message to the new_crypto_price topic.\"\n", + "\"answer\": \"The authentication/authorization requirement will depend on the API service that we choose for fetching the cryptocurrency prices. Some APIs might require it, while others might not. We will ensure to handle this aspect appropriately during the development phase.\"\n", "}\n", - "\u001b[32m*************************************************\u001b[0m\n", + "\u001b[32m**********************************************************\u001b[0m\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[35m\n", - ">>>>>>>> EXECUTING FUNCTION create_brief...\u001b[0m\n", - "create_brief(desc='We need to create a FastStream application that fetches the current prices for Bitcoin and Ethereum from the Coinbase API. The application will publish this data to a new_crypto_price topic every 2 seconds. The published message will be in JSON format and will contain two attributes: price (a non-negative float representing the current price in USD) and crypto_currency (a string representing the type of cryptocurrency, i.e., BTC or ETH). The application will use the utf-8 encoded crypto_currency attribute as a partition key when publishing the message to the new_crypto_price topic.')\n", + ">>>>>>>> EXECUTING FUNCTION continue_create_brief...\u001b[0m\n", + "continue_create_brief(answer='The authentication/authorization requirement will depend on the API service that we choose for fetching the cryptocurrency prices. Some APIs might require it, while others might not. We will ensure to handle this aspect appropriately during the development phase.')\n", + "create_brief(desc='The authentication/authorization requirement will depend on the API service that we choose for fetching the cryptocurrency prices. Some APIs might require it, while others might not. We will ensure to handle this aspect appropriately during the development phase.')\n", "\u001b[33mFunction_executor_proxy\u001b[0m (to chat_manager):\n", "\n", - "\u001b[32m***** Response from calling function \"create_brief\" *****\u001b[0m\n", + "\u001b[32m***** Response from calling function \"continue_create_brief\" *****\u001b[0m\n", "\n", " Create a FastStream application which will retrieve the current cryptocurrency price\n", " and publish it to new_crypto_price topic. \n", @@ -316,13 +389,38 @@ "\n", " To retrieve the prices, use the CryptoCompare API.\n", " Retrieve only Bitcoin and ETH prices.\n", - "\n", - "\u001b[32m*********************************************************\u001b[0m\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[32m******************************************************************\u001b[0m\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mProduct_owner\u001b[0m (to chat_manager):\n", "\n", - "The generated technical brief is correct and in line with the user requirements. The FastStream application will use the Coinbase API to fetch the cryptocurrency prices for Bitcoin and Ethereum and publish this data to a new topic 'new_crypto_price' every two seconds. The messages will be in JSON format with the attributes 'price' and 'crypto_currency'. The 'crypto_currency' attribute, which will be utf-8 encoded, will be used as a partition key for publishing the messages.\n", + "This technical brief seems to be in line with the client's requests. The application will:\n", + "\n", + "1. Retrieve the current cryptocurrency prices for Bitcoin and Ethereum.\n", + "2. Use the CryptoCompare API for fetching this data.\n", + "3. Retrieve the data every 2 seconds.\n", + "4. Publish the data to the 'new_crypto_price' Kafka topic.\n", + "5. The message will be a JSON with two attributes: 'price' and 'crypto_currency'. 'price' will represent the current price of the cryptocurrency in USD, and 'crypto_currency' will represent the type of cryptocurrency.\n", + "6. Use the 'crypto_currency' attribute, utf-8 encoded, as a partition key when publishing the message.\n", + "\n", + "If there are no further clarifications or changes, I believe we can proceed with this design.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mUser_proxy\u001b[0m (to chat_manager):\n", + "\n", + "Yes.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mFunction_executor_proxy\u001b[0m (to chat_manager):\n", + "\n", + "\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mUser_proxy\u001b[0m (to chat_manager):\n", @@ -344,9 +442,9 @@ "- price: non-negative float (current price of cryptocurrency in USD)\n", "- crypto_currency: string (the cryptocurrency e.g. BTC, ETH...)\n", "\n", + "\n", "Use utf-8 encoded crypto_currency attribute as a partition key when publishing\n", "the message to new_crypto_price topic.\n", - "\n", "\"\"\"\n", "\n", "initial_message = f\"\"\"{description}\n", @@ -354,13 +452,9 @@ "Is everything clear with the above description?\n", "\"\"\"\n", "\n", - "llm_config = {\n", - " \"config_list\": config_list,\n", - " \"seed\": 42,\n", - " \"temperature\": 0.7, # temperature for sampling\n", - "} \n", + "system_message=\"When you receive 'Suggested function Call:' the function should be executed by Function_executor_proxy.\"\n", "\n", - "groupchat = autogen.GroupChat(agents=[user_proxy, product_owner, function_executor_proxy], messages=[], max_round=20)\n", + "groupchat = autogen.GroupChat(agents=[user_proxy, product_owner, function_executor_proxy], messages=[], max_round=30)\n", "manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config)\n", "\n", "user_proxy.initiate_chat(manager, message=initial_message)\n", @@ -374,74 +468,6 @@ "metadata": {}, "outputs": [], "source": [] - }, - { - "cell_type": "code", - "execution_count": 9, - "id": "5d1a9f4e", - "metadata": {}, - "outputs": [ - { - "ename": "AssertionError", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[9], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28;01mFalse\u001b[39;00m\n", - "\u001b[0;31mAssertionError\u001b[0m: " - ] - } - ], - "source": [ - "assert False" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b2d34a13", - "metadata": {}, - "outputs": [], - "source": [ - "for message in reversed(product_owner.chat_messages[user_proxy]):\n", - " if 'function_call' in message:\n", - "# print(message[\"function_call\"])\n", - " create_brief_result = locals()[message[\"function_call\"][\"name\"]]()\n", - " print(create_brief_result)\n", - " break" - ] - }, - { - "cell_type": "markdown", - "id": "e1be8574", - "metadata": {}, - "source": [ - "## Continue the conversation" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "2f3207cc", - "metadata": {}, - "outputs": [], - "source": [ - "message = \"Updated application description:\\n\" + create_brief_result + \"\\nIf you agree with the application description above, type 'exit'?\"\n", - "product_owner.send(recipient=user_proxy, message=message)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "fea423f5", - "metadata": {}, - "outputs": [], - "source": [ - "for message in product_owner.chat_messages[user_proxy]:\n", - " role_message = f\"{message['role']}:\\n{message['content']}\"\n", - " print(role_message)" - ] } ], "metadata": { diff --git a/nbs/Tehnical_Design_Document.ipynb b/nbs/Tehnical_Design_Document.ipynb index dbac4b8..1d5d04e 100644 --- a/nbs/Tehnical_Design_Document.ipynb +++ b/nbs/Tehnical_Design_Document.ipynb @@ -24,7 +24,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 13, "id": "4b1ebd36", "metadata": {}, "outputs": [], @@ -50,7 +50,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 4, "id": "2b00a612", "metadata": {}, "outputs": [], @@ -62,11 +62,15 @@ "\n", "Your response should always be ONE of the following: \n", "1. If you have a question for the developer please ask it. Please ask ONE QUESTION at time.\n", - "2. Before you create a technical brief by suggesting the call of the create_tehnical_design_document, please list all assumptions and information and then verify with the developer that your understanding is correct.\n", - "3. If you have a question for the product owner (he can then ask the client if needed), or you do not know the answer for the developers question, suggest calling ask_product_owner function\n", "\n", - "Suggest calling create_tehnical_design_document function when everything is clear and you have no more questions.\n", - "If you have some additional question for the product owner, suggest calling ask_product_owner function\n", + "2. Before you create a technical brief by suggesting the call of the create_tehnical_design_document, \n", + "please list all assumptions and information and then verify with the developer that your understanding is correct.\n", + "\n", + "3. Suggest calling create_tehnical_design_document function when everything is clear and you have no more questions.\n", + "\n", + "4. If you have a question for the product owner (he can then ask the client if needed), or you do not know the answer for the developers question, \n", + "suggest calling ask_product_owner function\n", + "\n", "\n", "All details must be clear because after this we are starting with the implementation!\n", "If you need any details, such as: IP address, port, url, usernames, password... please ask the product owner as soon as possible!\n", @@ -75,7 +79,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 5, "id": "59938589", "metadata": {}, "outputs": [], @@ -97,7 +101,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 6, "id": "b9585965", "metadata": {}, "outputs": [], @@ -108,7 +112,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 7, "id": "3227b984", "metadata": {}, "outputs": [], @@ -119,7 +123,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 8, "id": "b9839221", "metadata": {}, "outputs": [], @@ -179,7 +183,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 9, "id": "80c36c84", "metadata": {}, "outputs": [], @@ -211,13 +215,14 @@ ")\n", "\n", "\n", + "\n", "groupchat = autogen.GroupChat(agents=[team_leader, developer, function_executor_proxy], messages=[], max_round=20)\n", "manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config, system_message=\"create_tehnical_design_document and ask_product_owner function should be executed by Function_executor_proxy.\")" ] }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 10, "id": "32f43817", "metadata": {}, "outputs": [ @@ -241,7 +246,6 @@ "Use utf-8 encoded crypto_currency attribute as a partition key when publishing\n", "the message to new_crypto_price topic.\n", "\n", - "To retrieve the prices, use the CryptoCompare API.\n", "Retrieve only Bitcoin and ETH prices.\n", "\n", "\n", @@ -251,60 +255,62 @@ "--------------------------------------------------------------------------------\n", "\u001b[33mDeveloper\u001b[0m (to chat_manager):\n", "\n", - "Technical Requirements:\n", + "TEHNICAL REQUIREMENTS:\n", "\n", "Python Libraries:\n", - "1. FastStream: For stream processing and publishing messages to the new_crypto_price topic.\n", - "2. Requests: To make requests to the CryptoCompare API to retrieve cryptocurrency prices.\n", - "3. JSON: To handle JSON data, which is used in the messages produced.\n", + "1. FastStream - for creating the application, publishing to topic\n", + "2. requests - for retrieving the cryptocurrency prices\n", + "3. json - for formatting the message\n", "\n", "Endpoints:\n", - "1. CryptoCompare API endpoint for retrieving the current price of Bitcoin and ETH.\n", + "1. An API endpoint from a cryptocurrency price service like CoinMarketCap or CryptoCompare will be required to fetch the current prices of Bitcoin and ETH.\n", "\n", - "Authentication:\n", - "1. If CryptoCompare API requires an API key for access, we need to register and get the key.\n", + "Authentication/Authorisation:\n", + "1. Depending on the API used for fetching the cryptocurrency prices, API keys may be required for authentication.\n", "\n", "Constraints:\n", - "1. The price must be a non-negative float representing the current price of the cryptocurrency in USD.\n", - "2. The crypto_currency attribute must be a string representing the cryptocurrency (BTC, ETH).\n", - "3. The crypto_currency attribute, utf-8 encoded, will be used as the partition key when publishing the message to the new_crypto_price topic.\n", - "4. The data must be retrieved every 2 seconds.\n", - "5. The message produced is in JSON format with two attributes: price and crypto_currency.\n", + "1. The price attribute in the JSON message should be a non-negative float representing the current price of the cryptocurrency in USD.\n", + "2. The crypto_currency attribute in the JSON message should be a string, either \"BTC\" or \"ETH\", and it will be used as the partition key when publishing the message to the 'new_crypto_price' topic.\n", + "3. The application should retrieve the data every 2 seconds.\n", + "4. The 'crypto_currency' attribute should be UTF-8 encoded.\n", + "5. The topic to which the messages are published is 'new_crypto_price'.\n", + "\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mTeam_leader\u001b[0m (to chat_manager):\n", "\n", - "Before we proceed with creating the technical design document, I just want to confirm my understanding of the requirements:\n", + "Before we proceed with the creation of the technical design document, I'd like to clarify a few things. \n", + "\n", + "Here are my assumptions based on the technical requirements you've provided:\n", "\n", - "1. We'll use Python's FastStream library for stream processing and publishing messages to a topic named 'new_crypto_price'.\n", - "2. We'll use the 'requests' library to make HTTP requests to CryptoCompare API for retrieving the current price of Bitcoin and Ethereum.\n", - "3. We'll use the 'json' library to handle JSON data.\n", - "4. Our application will retrieve data every 2 seconds.\n", - "5. The messages produced will be in JSON format and will contain two attributes - 'price' (a non-negative float representing the current price of the cryptocurrency in USD) and 'crypto_currency' (a string representing the type of cryptocurrency).\n", - "6. The 'crypto_currency' attribute, when utf-8 encoded, will be used as the partition key when publishing messages to the 'new_crypto_price' topic.\n", - "7. We might need an API key for accessing the CryptoCompare API, and if so, we'll need to register and obtain one.\n", + "1. We'll use the FastStream and requests Python libraries for this application.\n", + "2. We'll be using an API from a cryptocurrency price service like CoinMarketCap or CryptoCompare to fetch the current prices of Bitcoin and ETH.\n", + "3. There might be a need for API keys for authentication, depending on the chosen API.\n", + "4. The JSON message to be published to the 'new_crypto_price' topic will have two attributes: a non-negative float 'price' and a string 'crypto_currency'.\n", + "5. The 'crypto_currency' attribute will be UTF-8 encoded and used as the partition key when publishing the message.\n", + "6. The application will fetch data every 2 seconds.\n", "\n", - "Does this cover everything, or is there something I've missed or misunderstood?\n", + "Could you please confirm if my understanding of the requirements is correct?\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mDeveloper\u001b[0m (to chat_manager):\n", "\n", - "Your summary is correct, but it seems more like a confirmation rather than a question. If you have any specific technical questions regarding the application, please ask them.\n", + "Those are not technical questions. Please ask if something is not clear about the requirements.\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mTeam_leader\u001b[0m (to chat_manager):\n", "\n", - "I understand, thank you for your feedback. I do have a question: Do we have the specific CryptoCompare API endpoint that we will be using to retrieve the Bitcoin and Ethereum prices?\n", + "Alright, I would like to know which specific API service we will be using to fetch the cryptocurrency prices. This is important for us to know if we have to handle any particular API keys or specific request formats. Is it CoinMarketCap, CryptoCompare, or some other service?\n", "\n", "--------------------------------------------------------------------------------\n", - "\u001b[33mDeveloper\u001b[0m (to chat_manager):\n", + "\u001b[33mFunction_executor_proxy\u001b[0m (to chat_manager):\n", "\n", - "Please provide the specific CryptoCompare API endpoint to retrieve the Bitcoin and Ethereum prices.\n", "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33mFunction_executor_proxy\u001b[0m (to chat_manager):\n", "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mDeveloper\u001b[0m (to chat_manager):\n", "\n", + "The team leader did not provide an answer. Please ask your question again.\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mTeam_leader\u001b[0m (to chat_manager):\n", @@ -312,7 +318,7 @@ "\u001b[32m***** Suggested function Call: ask_product_owner *****\u001b[0m\n", "Arguments: \n", "{\n", - "\"question\": \"Could you please provide us with the specific CryptoCompare API endpoint that we will be using to retrieve the Bitcoin and Ethereum prices?\"\n", + "\"question\": \"Which specific API service will we be using to fetch the cryptocurrency prices? Is it CoinMarketCap, CryptoCompare, or some other service?\"\n", "}\n", "\u001b[32m******************************************************\u001b[0m\n", "\n", @@ -323,7 +329,7 @@ "\n", "\u001b[32m***** Response from calling function \"ask_product_owner\" *****\u001b[0m\n", "QUESTION:\n", - "Could you please provide us with the specific CryptoCompare API endpoint that we will be using to retrieve the Bitcoin and Ethereum prices?\n", + "Which specific API service will we be using to fetch the cryptocurrency prices? Is it CoinMarketCap, CryptoCompare, or some other service?\n", "TERMINATE\n", "\u001b[32m**************************************************************\u001b[0m\n", "\n", @@ -346,7 +352,6 @@ "Use utf-8 encoded crypto_currency attribute as a partition key when publishing\n", "the message to new_crypto_price topic.\n", "\n", - "To retrieve the prices, use the CryptoCompare API.\n", "Retrieve only Bitcoin and ETH prices.\n", "\n", "\n", @@ -358,7 +363,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 11, "id": "ca0ee646", "metadata": {}, "outputs": [ @@ -368,47 +373,79 @@ "text": [ "\u001b[33mTeam_leader\u001b[0m (to chat_manager):\n", "\n", - "https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD,JPY,EUR\n", + "No authentication is needed\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mDeveloper\u001b[0m (to chat_manager):\n", "\n", - "Thank you for the provided endpoint. We will use the CryptoCompare API endpoint https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD,JPY,EUR for retrieving the Bitcoin prices. \n", + "TEHNICAL REQUIREMENTS:\n", + "\n", + "Python Libraries:\n", + "1. FastStream - for creating the application, publishing to topic\n", + "2. requests - for retrieving the cryptocurrency prices\n", + "3. json - for formatting the message\n", + "\n", + "Endpoints:\n", + "1. An API endpoint from a cryptocurrency price service like CoinMarketCap or CryptoCompare will be required to fetch the current prices of Bitcoin and ETH.\n", + "\n", + "Authentication/Authorisation:\n", + "1. No authentication or authorisation is needed for the chosen API.\n", "\n", - "For the Ethereum prices, I assume we can replace 'BTC' with 'ETH' in the provided endpoint. Could you please confirm this?\n", + "Constraints:\n", + "1. The price attribute in the JSON message should be a non-negative float representing the current price of the cryptocurrency in USD.\n", + "2. The crypto_currency attribute in the JSON message should be a string, either \"BTC\" or \"ETH\", and it will be used as the partition key when publishing the message to the 'new_crypto_price' topic.\n", + "3. The application should retrieve the data every 2 seconds.\n", + "4. The 'crypto_currency' attribute should be UTF-8 encoded.\n", + "5. The topic to which the messages are published is 'new_crypto_price'.\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mTeam_leader\u001b[0m (to chat_manager):\n", "\n", - "\u001b[32m***** Suggested function Call: ask_product_owner *****\u001b[0m\n", + "\u001b[32m***** Suggested function Call: create_tehnical_design_document *****\u001b[0m\n", "Arguments: \n", "{\n", - "\"question\": \"Can we replace 'BTC' with 'ETH' in the provided CryptoCompare API endpoint to retrieve Ethereum prices?\"\n", + "\"desc\": \"Python Libraries:\\n1. FastStream - for creating the application, publishing to topic\\n2. requests - for retrieving the cryptocurrency prices\\n3. json - for formatting the message\\n\\nEndpoints:\\n1. An API endpoint from a cryptocurrency price service like CoinMarketCap or CryptoCompare will be required to fetch the current prices of Bitcoin and ETH.\\n\\nAuthentication/Authorisation:\\n1. No authentication or authorisation is needed for the chosen API.\\n\\nConstraints:\\n1. The price attribute in the JSON message should be a non-negative float representing the current price of the cryptocurrency in USD.\\n2. The crypto_currency attribute in the JSON message should be a string, either 'BTC' or 'ETH', and it will be used as the partition key when publishing the message to the 'new_crypto_price' topic.\\n3. The application should retrieve the data every 2 seconds.\\n4. The 'crypto_currency' attribute should be UTF-8 encoded.\\n5. The topic to which the messages are published is 'new_crypto_price'.\"\n", "}\n", - "\u001b[32m******************************************************\u001b[0m\n", + "\u001b[32m********************************************************************\u001b[0m\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[35m\n", - ">>>>>>>> EXECUTING FUNCTION ask_product_owner...\u001b[0m\n", + ">>>>>>>> EXECUTING FUNCTION create_tehnical_design_document...\u001b[0m\n", "\u001b[33mFunction_executor_proxy\u001b[0m (to chat_manager):\n", "\n", - "\u001b[32m***** Response from calling function \"ask_product_owner\" *****\u001b[0m\n", - "QUESTION:\n", - "Can we replace 'BTC' with 'ETH' in the provided CryptoCompare API endpoint to retrieve Ethereum prices?\n", + "\u001b[32m***** Response from calling function \"create_tehnical_design_document\" *****\u001b[0m\n", + "TEHNICAL DESIGN DOCUMENT:\n", + "Python Libraries:\n", + "1. FastStream - for creating the application, publishing to topic\n", + "2. requests - for retrieving the cryptocurrency prices\n", + "3. json - for formatting the message\n", + "\n", + "Endpoints:\n", + "1. An API endpoint from a cryptocurrency price service like CoinMarketCap or CryptoCompare will be required to fetch the current prices of Bitcoin and ETH.\n", + "\n", + "Authentication/Authorisation:\n", + "1. No authentication or authorisation is needed for the chosen API.\n", + "\n", + "Constraints:\n", + "1. The price attribute in the JSON message should be a non-negative float representing the current price of the cryptocurrency in USD.\n", + "2. The crypto_currency attribute in the JSON message should be a string, either 'BTC' or 'ETH', and it will be used as the partition key when publishing the message to the 'new_crypto_price' topic.\n", + "3. The application should retrieve the data every 2 seconds.\n", + "4. The 'crypto_currency' attribute should be UTF-8 encoded.\n", + "5. The topic to which the messages are published is 'new_crypto_price'.\n", "TERMINATE\n", - "\u001b[32m**************************************************************\u001b[0m\n", + "\u001b[32m****************************************************************************\u001b[0m\n", "\n", "--------------------------------------------------------------------------------\n" ] } ], "source": [ - "team_leader.send(recipient=manager, message=\"https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD,JPY,EUR\")" + "team_leader.send(recipient=manager, message=\"No authentication is needed\")" ] }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 12, "id": "c04eba16", "metadata": {}, "outputs": [ @@ -423,51 +460,97 @@ "--------------------------------------------------------------------------------\n", "\u001b[33mDeveloper\u001b[0m (to chat_manager):\n", "\n", - "Great! With that confirmation, we have the CryptoCompare API endpoints for both Bitcoin and Ethereum:\n", - "1. Bitcoin: https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD,JPY,EUR\n", - "2. Ethereum: https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD,JPY,EUR\n", + "Great! With the technical requirements and design document now finalized, we can proceed with the implementation phase of the FastStream application.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mDeveloper\u001b[0m (to chat_manager):\n", + "\n", + "Great! With the technical requirements and design document now finalized, we can proceed with the implementation phase of the FastStream application.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mFunction_executor_proxy\u001b[0m (to chat_manager):\n", + "\n", "\n", - "We can now proceed with the implementation.\n", "\n", "--------------------------------------------------------------------------------\n", "\u001b[33mTeam_leader\u001b[0m (to chat_manager):\n", "\n", - "\u001b[32m***** Suggested function Call: create_tehnical_design_document *****\u001b[0m\n", - "Arguments: \n", - "{\n", - "\"desc\": \"Technical Requirements:\\n\\nPython Libraries:\\n1. FastStream: For stream processing and publishing messages to the new_crypto_price topic.\\n2. Requests: To make requests to the CryptoCompare API to retrieve cryptocurrency prices.\\n3. JSON: To handle JSON data, which is used in the messages produced.\\n\\nEndpoints:\\n1. CryptoCompare API endpoint for retrieving the current price of Bitcoin: https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD,JPY,EUR\\n2. CryptoCompare API endpoint for retrieving the current price of Ethereum: https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD,JPY,EUR\\n\\nAuthentication:\\n1. If CryptoCompare API requires an API key for access, we need to register and get the key.\\n\\nConstraints:\\n1. The price must be a non-negative float representing the current price of the cryptocurrency in USD.\\n2. The crypto_currency attribute must be a string representing the cryptocurrency (BTC, ETH).\\n3. The crypto_currency attribute, utf-8 encoded, will be used as the partition key when publishing the message to the new_crypto_price topic.\\n4. The data must be retrieved every 2 seconds.\\n5. The message produced is in JSON format with two attributes: price and crypto_currency.\"\n", - "}\n", - "\u001b[32m********************************************************************\u001b[0m\n", + "Great! With the technical requirements and design document now finalized, we can proceed with the implementation phase of the FastStream application.\n", "\n", "--------------------------------------------------------------------------------\n", - "\u001b[35m\n", - ">>>>>>>> EXECUTING FUNCTION create_tehnical_design_document...\u001b[0m\n", "\u001b[33mFunction_executor_proxy\u001b[0m (to chat_manager):\n", "\n", - "\u001b[32m***** Response from calling function \"create_tehnical_design_document\" *****\u001b[0m\n", - "TEHNICAL DESIGN DOCUMENT:\n", - "Technical Requirements:\n", "\n", - "Python Libraries:\n", - "1. FastStream: For stream processing and publishing messages to the new_crypto_price topic.\n", - "2. Requests: To make requests to the CryptoCompare API to retrieve cryptocurrency prices.\n", - "3. JSON: To handle JSON data, which is used in the messages produced.\n", "\n", - "Endpoints:\n", - "1. CryptoCompare API endpoint for retrieving the current price of Bitcoin: https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD,JPY,EUR\n", - "2. CryptoCompare API endpoint for retrieving the current price of Ethereum: https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD,JPY,EUR\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mDeveloper\u001b[0m (to chat_manager):\n", "\n", - "Authentication:\n", - "1. If CryptoCompare API requires an API key for access, we need to register and get the key.\n", + "Great! With the technical requirements and design document now finalized, we can proceed with the implementation phase of the FastStream application.\n", "\n", - "Constraints:\n", - "1. The price must be a non-negative float representing the current price of the cryptocurrency in USD.\n", - "2. The crypto_currency attribute must be a string representing the cryptocurrency (BTC, ETH).\n", - "3. The crypto_currency attribute, utf-8 encoded, will be used as the partition key when publishing the message to the new_crypto_price topic.\n", - "4. The data must be retrieved every 2 seconds.\n", - "5. The message produced is in JSON format with two attributes: price and crypto_currency.\n", - "TERMINATE\n", - "\u001b[32m****************************************************************************\u001b[0m\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mTeam_leader\u001b[0m (to chat_manager):\n", + "\n", + "Great! With the technical requirements and design document now finalized, we can proceed with the implementation phase of the FastStream application.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mFunction_executor_proxy\u001b[0m (to chat_manager):\n", + "\n", + "\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mDeveloper\u001b[0m (to chat_manager):\n", + "\n", + "Great! With the technical requirements and design document now finalized, we can proceed with the implementation phase of the FastStream application.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mFunction_executor_proxy\u001b[0m (to chat_manager):\n", + "\n", + "\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mTeam_leader\u001b[0m (to chat_manager):\n", + "\n", + "Great! With the technical requirements and design document now finalized, we can proceed with the implementation phase of the FastStream application.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mDeveloper\u001b[0m (to chat_manager):\n", + "\n", + "Great! With the technical requirements and design document now finalized, we can proceed with the implementation phase of the FastStream application.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mFunction_executor_proxy\u001b[0m (to chat_manager):\n", + "\n", + "\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mTeam_leader\u001b[0m (to chat_manager):\n", + "\n", + "Great! With the technical requirements and design document now finalized, we can proceed with the implementation phase of the FastStream application.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mDeveloper\u001b[0m (to chat_manager):\n", + "\n", + "Great! With the technical requirements and design document now finalized, we can proceed with the implementation phase of the FastStream application.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mFunction_executor_proxy\u001b[0m (to chat_manager):\n", + "\n", + "\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mTeam_leader\u001b[0m (to chat_manager):\n", + "\n", + "Great! With the technical requirements and design document now finalized, we can proceed with the implementation phase of the FastStream application.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mDeveloper\u001b[0m (to chat_manager):\n", + "\n", + "Great! With the technical requirements and design document now finalized, we can proceed with the implementation phase of the FastStream application.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mDeveloper\u001b[0m (to chat_manager):\n", + "\n", + "Great! With the technical requirements and design document now finalized, we can proceed with the implementation phase of the FastStream application.\n", "\n", "--------------------------------------------------------------------------------\n" ]