diff --git a/metagpt/actions/import_repo.py b/metagpt/actions/import_repo.py index 5b1624a2f..82aa916f4 100644 --- a/metagpt/actions/import_repo.py +++ b/metagpt/actions/import_repo.py @@ -1,5 +1,14 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +""" + +This script defines an action to import a Git repository into the MetaGPT project format, enabling incremental + appending of requirements. +The MetaGPT project format encompasses a structured representation of project data compatible with MetaGPT's + capabilities, facilitating the integration of Git repositories into MetaGPT workflows while allowing for the gradual + addition of requirements. + +""" import json import re from pathlib import Path @@ -30,11 +39,30 @@ from metagpt.utils.project_repo import ProjectRepo class ImportRepo(Action): - repo_path: str - graph_db: Optional[GraphRepository] = None - rid: str = "" + """ + An action to import a Git repository into a graph database and create related artifacts. + + Attributes: + repo_path (str): The URL of the Git repository to import. + graph_db (Optional[GraphRepository]): The output graph database of the Git repository. + rid (str): The output requirement ID. + """ + + repo_path: str # input, git repo url. + graph_db: Optional[GraphRepository] = None # output. graph db of the git repository + rid: str = "" # output, requirement ID. async def run(self, with_messages: List[Message] = None, **kwargs) -> Message: + """ + Runs the import process for the Git repository. + + Args: + with_messages (List[Message], optional): Additional messages to include. + **kwargs: Additional keyword arguments. + + Returns: + Message: A message indicating the completion of the import process. + """ await self._create_repo() await self._create_prd() await self._create_system_design() diff --git a/metagpt/roles/engineer.py b/metagpt/roles/engineer.py index b07973ed4..60871045d 100644 --- a/metagpt/roles/engineer.py +++ b/metagpt/roles/engineer.py @@ -267,7 +267,7 @@ class Engineer(Role): return self.rc.todo return None - async def _new_coding_context(self, filename, dependency) -> CodingContext: + async def _new_coding_context(self, filename, dependency) -> Optional[CodingContext]: old_code_doc = await self.project_repo.srcs.get(filename) if not old_code_doc: old_code_doc = Document(root_path=str(self.project_repo.src_relative_path), filename=filename, content="") @@ -283,6 +283,8 @@ class Engineer(Role): elif str(i.parent) == CODE_PLAN_AND_CHANGE_FILE_REPO: code_plan_and_change_doc = await self.project_repo.docs.code_plan_and_change.get(i.name) if not task_doc or not design_doc: + if filename == "__init__.py": # `__init__.py` created by `init_python_folder` + return None logger.error(f'Detected source code "{filename}" from an unknown origin.') raise ValueError(f'Detected source code "{filename}" from an unknown origin.') context = CodingContext( @@ -294,8 +296,10 @@ class Engineer(Role): ) return context - async def _new_coding_doc(self, filename, dependency): + async def _new_coding_doc(self, filename, dependency) -> Optional[Document]: context = await self._new_coding_context(filename, dependency) + if not context: + return None # `__init__.py` created by `init_python_folder` coding_doc = Document( root_path=str(self.project_repo.src_relative_path), filename=filename, content=context.model_dump_json() ) @@ -352,6 +356,8 @@ class Engineer(Role): if filename in changed_files.docs: continue coding_doc = await self._new_coding_doc(filename=filename, dependency=dependency) + if not coding_doc: + continue # `__init__.py` created by `init_python_folder` changed_files.docs[filename] = coding_doc self.code_todos.append(WriteCode(i_context=coding_doc, context=self.context, llm=self.llm)) diff --git a/metagpt/roles/qa_engineer.py b/metagpt/roles/qa_engineer.py index c73c10ef3..04440c1cb 100644 --- a/metagpt/roles/qa_engineer.py +++ b/metagpt/roles/qa_engineer.py @@ -21,7 +21,7 @@ from metagpt.const import MESSAGE_ROUTE_TO_NONE from metagpt.logs import logger from metagpt.roles import Role from metagpt.schema import Document, Message, RunCodeContext, TestingContext -from metagpt.utils.common import any_to_str_set, parse_recipient +from metagpt.utils.common import any_to_str_set, init_python_folder, parse_recipient class QaEngineer(Role): @@ -141,6 +141,7 @@ class QaEngineer(Role): ) async def _act(self) -> Message: + await init_python_folder(self.project_repo.tests.workdir) if self.test_round > self.test_round_allowed: result_msg = Message( content=f"Exceeding {self.test_round_allowed} rounds of tests, skip (writing code counts as a round, too)", diff --git a/metagpt/tools/libs/software_development.py b/metagpt/tools/libs/software_development.py index 41d6fec57..de05eacf9 100644 --- a/metagpt/tools/libs/software_development.py +++ b/metagpt/tools/libs/software_development.py @@ -270,3 +270,32 @@ async def git_archive(project_path: str | Path) -> str: ctx.set_repo_dir(project_path) ctx.git_repo.archive() return ctx.git_repo.log() + + +@register_tool(tags=["software development", "import git repo"]) +async def import_git_repo(url: str) -> Path: + """ + Imports a project from a Git website and formats it to MetaGPT project format to enable incremental appending requirements. + + Args: + url (str): The Git project URL, such as "https://github.com/geekan/MetaGPT.git". + + Returns: + Path: The path of the formatted project. + + Example: + # The Git project URL to input + >>> git_url = "https://github.com/geekan/MetaGPT.git" + + # Import the Git repository and get the formatted project path + >>> formatted_project_path = await import_git_repo(git_url) + >>> print("Formatted project path:", formatted_project_path) + /PATH/TO/THE/FORMMATTED/PROJECT + """ + from metagpt.actions.import_repo import ImportRepo + from metagpt.context import Context + + ctx = Context() + action = ImportRepo(repo_path=url, context=ctx) + await action.run() + return ctx.repo.workdir diff --git a/metagpt/utils/git_repository.py b/metagpt/utils/git_repository.py index 8ed22cadf..2d2927806 100644 --- a/metagpt/utils/git_repository.py +++ b/metagpt/utils/git_repository.py @@ -251,6 +251,8 @@ class GitRepository: if not directory_path.exists(): return [] for file_path in directory_path.iterdir(): + if not file_path.is_relative_to(root_relative_path): + continue if file_path.is_file(): rpath = file_path.relative_to(root_relative_path) files.append(str(rpath)) diff --git a/tests/data/rsp_cache.json b/tests/data/rsp_cache.json index 565241779..1cfb4b1ed 100644 --- a/tests/data/rsp_cache.json +++ b/tests/data/rsp_cache.json @@ -427,5 +427,27 @@ "As a data scientist, you need to help user to achieve their goal step by step in a continuous Jupyter notebook. Since it is a notebook environment, don't use asyncio.run. Instead, use await if you need to call an async function.#SYSTEM_MSG_END#\n# User Requirement\nRun data analysis on sklearn Wine recognition dataset, include a plot, and train a model to predict wine class (20% as validation), and show validation accuracy.\n\n# Plan Status\n\n## Finished Tasks\n### code\n```python\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom sklearn.datasets import load_wine\nwine = load_wine()\nwine_df = pd.DataFrame(data=np.c_[wine['data'], wine['target']],\n columns=wine['feature_names'] + ['target'])\nnumerical_summary = wine_df.describe()\ncategorical_summary = wine_df.select_dtypes(include=['object', 'category']).describe()\ncorrelation_matrix = wine_df.corr()\nwine_df.hist(bins=15, figsize=(15, 10), layout=(4, 4))\nplt.tight_layout()\nplt.show()\nprint(\"Numerical Summary:\\n\", numerical_summary)\nprint(\"\\nCategorical Summary:\\n\", categorical_summary)\nprint(\"\\nCorrelation Matrix:\\n\", correlation_matrix)\n\nfrom sklearn.model_selection import train_test_split\nX_train, X_val, y_train, y_val = train_test_split(\n wine_df.drop('target', axis=1),\n wine_df['target'],\n test_size=0.2,\n random_state=42\n)\nprint(f\"Training set shape: {X_train.shape}\")\nprint(f\"Validation set shape: {X_val.shape}\")\nprint(f\"Training target shape: {y_train.shape}\")\nprint(f\"Validation target shape: {y_val.shape}\")\n\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.metrics import accuracy_score\nmodel = RandomForestClassifier(n_estimators=100, random_state=42)\nmodel.fit(X_train, y_train)\ny_val_pred = model.predict(X_val)\nval_accuracy = accuracy_score(y_val, y_val_pred)\nprint(f\"Validation Accuracy: {val_accuracy:.4f}\")\n```\n\n### execution result\na successful run\n\na successful run\n\na successful run\n\n## Current Task\nEvaluate the model on the validation set and show the validation accuracy.\n\n## Task Guidance\nWrite complete code for 'Current Task'. And avoid duplicating code from 'Finished Tasks', such as repeated import of packages, reading data, etc.\nSpecifically, \nThe current task is about evaluating a model, please note the following:\n- Ensure that the evaluated data is same processed as the training data. If not, remember use object in 'Done Tasks' to transform the data.\n- Use trained model from previous task result directly, do not mock or reload model yourself.\n\n\n\n# Tool Info\n\n\n# Constraints\n- Take on Current Task if it is in Plan Status, otherwise, tackle User Requirement directly.\n- Ensure the output new code is executable in the same Jupyter notebook as the previous executed code.\n- Always prioritize using pre-defined tools for the same functionality.\n\n# Output\nWhile some concise thoughts are helpful, code is absolutely required. Always output one and only one code block in your response. Output code in the following format:\n```python\nyour code\n```\n": "```python\n# Evaluate the model on the validation set and show the validation accuracy\nval_accuracy = accuracy_score(y_val, y_val_pred)\nprint(f\"Validation Accuracy: {val_accuracy:.4f}\")\n```", "user: \n## User Requirement\nRun data analysis on sklearn Wine recognition dataset, include a plot, and train a model to predict wine class (20% as validation), and show validation accuracy.\n## Context\n\n## Current Plan\n[\n {\n \"task_id\": \"1\",\n \"dependent_task_ids\": [],\n \"instruction\": \"Perform exploratory data analysis on the sklearn Wine recognition dataset including summary statistics and a plot.\",\n \"task_type\": \"eda\",\n \"code\": \"import numpy as np\\nimport pandas as pd\\nimport matplotlib.pyplot as plt\\nfrom sklearn.datasets import load_wine\\n\\n# Load the wine dataset\\nwine = load_wine()\\nwine_df = pd.DataFrame(data=np.c_[wine['data'], wine['target']],\\n columns=wine['feature_names'] + ['target'])\\n\\n# Summary statistics for numerical features\\nnumerical_summary = wine_df.describe()\\n\\n# Summary statistics for categorical features\\ncategorical_summary = wine_df.select_dtypes(include=['object', 'category']).describe()\\n\\n# Correlation matrix for numerical features\\ncorrelation_matrix = wine_df.corr()\\n\\n# Plotting a histogram for each numerical feature\\nwine_df.hist(bins=15, figsize=(15, 10), layout=(4, 4))\\nplt.tight_layout()\\nplt.show()\\n\\n# Displaying the summary statistics\\nprint(\\\"Numerical Summary:\\\\n\\\", numerical_summary)\\nprint(\\\"\\\\nCategorical Summary:\\\\n\\\", categorical_summary)\\nprint(\\\"\\\\nCorrelation Matrix:\\\\n\\\", correlation_matrix)\\n\",\n \"result\": \"a successful run\",\n \"is_success\": true,\n \"is_finished\": true\n },\n {\n \"task_id\": \"2\",\n \"dependent_task_ids\": [\n \"1\"\n ],\n \"instruction\": \"Preprocess the dataset by splitting it into training and validation sets with a 80-20 split.\",\n \"task_type\": \"data preprocessing\",\n \"code\": \"\",\n \"result\": \"\",\n \"is_success\": false,\n \"is_finished\": false\n },\n {\n \"task_id\": \"3\",\n \"dependent_task_ids\": [\n \"2\"\n ],\n \"instruction\": \"Train a model using the training set to predict wine class.\",\n \"task_type\": \"model train\",\n \"code\": \"\",\n \"result\": \"\",\n \"is_success\": false,\n \"is_finished\": false\n },\n {\n \"task_id\": \"4\",\n \"dependent_task_ids\": [\n \"3\"\n ],\n \"instruction\": \"Evaluate the model on the validation set and show the validation accuracy.\",\n \"task_type\": \"model evaluate\",\n \"code\": \"\",\n \"result\": \"\",\n \"is_success\": false,\n \"is_finished\": false\n }\n]\n## Current Task\n{\"task_id\":\"2\",\"dependent_task_ids\":[\"1\"],\"instruction\":\"Preprocess the dataset by splitting it into training and validation sets with a 80-20 split.\",\"task_type\":\"data preprocessing\",\"code\":\"\",\"result\":\"\",\"is_success\":false,\"is_finished\":false}\n\nuser: \n# Latest Data Info\nLatest data info after previous tasks:\na successful run\n\nassistant: from sklearn.model_selection import train_test_split\n\n# Split the data into training and validation sets (80-20 split)\nX_train, X_val, y_train, y_val = train_test_split(\n wine_df.drop('target', axis=1), # features\n wine_df['target'], # target variable\n test_size=0.2, # 20% for validation\n random_state=42 # seed for reproducibility\n)\n\n# Output the shapes of the resulting data splits\nprint(f\"Training set shape: {X_train.shape}\")\nprint(f\"Validation set shape: {X_val.shape}\")\nprint(f\"Training target shape: {y_train.shape}\")\nprint(f\"Validation target shape: {y_val.shape}\")\n\nuser: a successful runThis is a review. Please review output from metagpt.actions.di.execute_nb_code.ExecuteNbCode\nIf you want to change, add, delete a task or merge tasks in the plan, say 'change task task_id or current task, ... (things to change)' If you confirm the output from the current task and wish to continue, type: confirmIf you think user requirement has been fulfilled completedly, you can finish the process by typing: finish\nIf you want to terminate the process, type: exit\nPlease type your review below:\n": "confirm", "user: \n## User Requirement\nRun data analysis on sklearn Wine recognition dataset, include a plot, and train a model to predict wine class (20% as validation), and show validation accuracy.\n## Context\n\n## Current Plan\n[\n {\n \"task_id\": \"1\",\n \"dependent_task_ids\": [],\n \"instruction\": \"Perform exploratory data analysis on the sklearn Wine recognition dataset including summary statistics and a plot.\",\n \"task_type\": \"eda\",\n \"code\": \"import numpy as np\\nimport pandas as pd\\nimport matplotlib.pyplot as plt\\nfrom sklearn.datasets import load_wine\\n\\n# Load the wine dataset\\nwine = load_wine()\\nwine_df = pd.DataFrame(data=np.c_[wine['data'], wine['target']],\\n columns=wine['feature_names'] + ['target'])\\n\\n# Summary statistics for numerical features\\nnumerical_summary = wine_df.describe()\\n\\n# Summary statistics for categorical features\\ncategorical_summary = wine_df.select_dtypes(include=['object', 'category']).describe()\\n\\n# Correlation matrix for numerical features\\ncorrelation_matrix = wine_df.corr()\\n\\n# Plotting a histogram for each numerical feature\\nwine_df.hist(bins=15, figsize=(15, 10), layout=(4, 4))\\nplt.tight_layout()\\nplt.show()\\n\\n# Displaying the summary statistics\\nprint(\\\"Numerical Summary:\\\\n\\\", numerical_summary)\\nprint(\\\"\\\\nCategorical Summary:\\\\n\\\", categorical_summary)\\nprint(\\\"\\\\nCorrelation Matrix:\\\\n\\\", correlation_matrix)\\n\",\n \"result\": \"a successful run\",\n \"is_success\": true,\n \"is_finished\": true\n },\n {\n \"task_id\": \"2\",\n \"dependent_task_ids\": [\n \"1\"\n ],\n \"instruction\": \"Preprocess the dataset by splitting it into training and validation sets with a 80-20 split.\",\n \"task_type\": \"data preprocessing\",\n \"code\": \"from sklearn.model_selection import train_test_split\\n\\n# Split the data into training and validation sets (80-20 split)\\nX_train, X_val, y_train, y_val = train_test_split(\\n wine_df.drop('target', axis=1), # features\\n wine_df['target'], # target variable\\n test_size=0.2, # 20% for validation\\n random_state=42 # seed for reproducibility\\n)\\n\\n# Output the shapes of the resulting data splits\\nprint(f\\\"Training set shape: {X_train.shape}\\\")\\nprint(f\\\"Validation set shape: {X_val.shape}\\\")\\nprint(f\\\"Training target shape: {y_train.shape}\\\")\\nprint(f\\\"Validation target shape: {y_val.shape}\\\")\\n\",\n \"result\": \"a successful run\",\n \"is_success\": true,\n \"is_finished\": true\n },\n {\n \"task_id\": \"3\",\n \"dependent_task_ids\": [\n \"2\"\n ],\n \"instruction\": \"Train a model using the training set to predict wine class.\",\n \"task_type\": \"model train\",\n \"code\": \"\",\n \"result\": \"\",\n \"is_success\": false,\n \"is_finished\": false\n },\n {\n \"task_id\": \"4\",\n \"dependent_task_ids\": [\n \"3\"\n ],\n \"instruction\": \"Evaluate the model on the validation set and show the validation accuracy.\",\n \"task_type\": \"model evaluate\",\n \"code\": \"\",\n \"result\": \"\",\n \"is_success\": false,\n \"is_finished\": false\n }\n]\n## Current Task\n{\"task_id\":\"3\",\"dependent_task_ids\":[\"2\"],\"instruction\":\"Train a model using the training set to predict wine class.\",\"task_type\":\"model train\",\"code\":\"\",\"result\":\"\",\"is_success\":false,\"is_finished\":false}\n\nuser: \n# Latest Data Info\nLatest data info after previous tasks:\na successful run\n\nassistant: from sklearn.ensemble import RandomForestClassifier\nfrom sklearn.metrics import accuracy_score\n\n# Initialize the RandomForestClassifier\nmodel = RandomForestClassifier(n_estimators=100, random_state=42)\n\n# Train the model on the training data\nmodel.fit(X_train, y_train)\n\n# Predict the wine classes on the validation set\ny_val_pred = model.predict(X_val)\n\n# Calculate the accuracy on the validation set\nval_accuracy = accuracy_score(y_val, y_val_pred)\n\nprint(f\"Validation Accuracy: {val_accuracy:.4f}\")\n\nuser: a successful runThis is a review. Please review output from metagpt.actions.di.execute_nb_code.ExecuteNbCode\nIf you want to change, add, delete a task or merge tasks in the plan, say 'change task task_id or current task, ... (things to change)' If you confirm the output from the current task and wish to continue, type: confirmIf you think user requirement has been fulfilled completedly, you can finish the process by typing: finish\nIf you want to terminate the process, type: exit\nPlease type your review below:\n": "confirm", - "user: \n## User Requirement\nRun data analysis on sklearn Wine recognition dataset, include a plot, and train a model to predict wine class (20% as validation), and show validation accuracy.\n## Context\n\n## Current Plan\n[\n {\n \"task_id\": \"1\",\n \"dependent_task_ids\": [],\n \"instruction\": \"Perform exploratory data analysis on the sklearn Wine recognition dataset including summary statistics and a plot.\",\n \"task_type\": \"eda\",\n \"code\": \"import numpy as np\\nimport pandas as pd\\nimport matplotlib.pyplot as plt\\nfrom sklearn.datasets import load_wine\\n\\n# Load the wine dataset\\nwine = load_wine()\\nwine_df = pd.DataFrame(data=np.c_[wine['data'], wine['target']],\\n columns=wine['feature_names'] + ['target'])\\n\\n# Summary statistics for numerical features\\nnumerical_summary = wine_df.describe()\\n\\n# Summary statistics for categorical features\\ncategorical_summary = wine_df.select_dtypes(include=['object', 'category']).describe()\\n\\n# Correlation matrix for numerical features\\ncorrelation_matrix = wine_df.corr()\\n\\n# Plotting a histogram for each numerical feature\\nwine_df.hist(bins=15, figsize=(15, 10), layout=(4, 4))\\nplt.tight_layout()\\nplt.show()\\n\\n# Displaying the summary statistics\\nprint(\\\"Numerical Summary:\\\\n\\\", numerical_summary)\\nprint(\\\"\\\\nCategorical Summary:\\\\n\\\", categorical_summary)\\nprint(\\\"\\\\nCorrelation Matrix:\\\\n\\\", correlation_matrix)\\n\",\n \"result\": \"a successful run\",\n \"is_success\": true,\n \"is_finished\": true\n },\n {\n \"task_id\": \"2\",\n \"dependent_task_ids\": [\n \"1\"\n ],\n \"instruction\": \"Preprocess the dataset by splitting it into training and validation sets with a 80-20 split.\",\n \"task_type\": \"data preprocessing\",\n \"code\": \"from sklearn.model_selection import train_test_split\\n\\n# Split the data into training and validation sets (80-20 split)\\nX_train, X_val, y_train, y_val = train_test_split(\\n wine_df.drop('target', axis=1), # features\\n wine_df['target'], # target variable\\n test_size=0.2, # 20% for validation\\n random_state=42 # seed for reproducibility\\n)\\n\\n# Output the shapes of the resulting data splits\\nprint(f\\\"Training set shape: {X_train.shape}\\\")\\nprint(f\\\"Validation set shape: {X_val.shape}\\\")\\nprint(f\\\"Training target shape: {y_train.shape}\\\")\\nprint(f\\\"Validation target shape: {y_val.shape}\\\")\\n\",\n \"result\": \"a successful run\",\n \"is_success\": true,\n \"is_finished\": true\n },\n {\n \"task_id\": \"3\",\n \"dependent_task_ids\": [\n \"2\"\n ],\n \"instruction\": \"Train a model using the training set to predict wine class.\",\n \"task_type\": \"model train\",\n \"code\": \"from sklearn.ensemble import RandomForestClassifier\\nfrom sklearn.metrics import accuracy_score\\n\\n# Initialize the RandomForestClassifier\\nmodel = RandomForestClassifier(n_estimators=100, random_state=42)\\n\\n# Train the model on the training data\\nmodel.fit(X_train, y_train)\\n\\n# Predict the wine classes on the validation set\\ny_val_pred = model.predict(X_val)\\n\\n# Calculate the accuracy on the validation set\\nval_accuracy = accuracy_score(y_val, y_val_pred)\\n\\nprint(f\\\"Validation Accuracy: {val_accuracy:.4f}\\\")\\n\",\n \"result\": \"a successful run\",\n \"is_success\": true,\n \"is_finished\": true\n },\n {\n \"task_id\": \"4\",\n \"dependent_task_ids\": [\n \"3\"\n ],\n \"instruction\": \"Evaluate the model on the validation set and show the validation accuracy.\",\n \"task_type\": \"model evaluate\",\n \"code\": \"\",\n \"result\": \"\",\n \"is_success\": false,\n \"is_finished\": false\n }\n]\n## Current Task\n{\"task_id\":\"4\",\"dependent_task_ids\":[\"3\"],\"instruction\":\"Evaluate the model on the validation set and show the validation accuracy.\",\"task_type\":\"model evaluate\",\"code\":\"\",\"result\":\"\",\"is_success\":false,\"is_finished\":false}\n\nassistant: # Evaluate the model on the validation set and show the validation accuracy\nval_accuracy = accuracy_score(y_val, y_val_pred)\nprint(f\"Validation Accuracy: {val_accuracy:.4f}\")\n\nuser: a successful runThis is a review. Please review output from metagpt.actions.di.execute_nb_code.ExecuteNbCode\nIf you want to change, add, delete a task or merge tasks in the plan, say 'change task task_id or current task, ... (things to change)' If you confirm the output from the current task and wish to continue, type: confirmIf you think user requirement has been fulfilled completedly, you can finish the process by typing: finish\nIf you want to terminate the process, type: exit\nPlease type your review below:\n": "confirm" + "user: \n## User Requirement\nRun data analysis on sklearn Wine recognition dataset, include a plot, and train a model to predict wine class (20% as validation), and show validation accuracy.\n## Context\n\n## Current Plan\n[\n {\n \"task_id\": \"1\",\n \"dependent_task_ids\": [],\n \"instruction\": \"Perform exploratory data analysis on the sklearn Wine recognition dataset including summary statistics and a plot.\",\n \"task_type\": \"eda\",\n \"code\": \"import numpy as np\\nimport pandas as pd\\nimport matplotlib.pyplot as plt\\nfrom sklearn.datasets import load_wine\\n\\n# Load the wine dataset\\nwine = load_wine()\\nwine_df = pd.DataFrame(data=np.c_[wine['data'], wine['target']],\\n columns=wine['feature_names'] + ['target'])\\n\\n# Summary statistics for numerical features\\nnumerical_summary = wine_df.describe()\\n\\n# Summary statistics for categorical features\\ncategorical_summary = wine_df.select_dtypes(include=['object', 'category']).describe()\\n\\n# Correlation matrix for numerical features\\ncorrelation_matrix = wine_df.corr()\\n\\n# Plotting a histogram for each numerical feature\\nwine_df.hist(bins=15, figsize=(15, 10), layout=(4, 4))\\nplt.tight_layout()\\nplt.show()\\n\\n# Displaying the summary statistics\\nprint(\\\"Numerical Summary:\\\\n\\\", numerical_summary)\\nprint(\\\"\\\\nCategorical Summary:\\\\n\\\", categorical_summary)\\nprint(\\\"\\\\nCorrelation Matrix:\\\\n\\\", correlation_matrix)\\n\",\n \"result\": \"a successful run\",\n \"is_success\": true,\n \"is_finished\": true\n },\n {\n \"task_id\": \"2\",\n \"dependent_task_ids\": [\n \"1\"\n ],\n \"instruction\": \"Preprocess the dataset by splitting it into training and validation sets with a 80-20 split.\",\n \"task_type\": \"data preprocessing\",\n \"code\": \"from sklearn.model_selection import train_test_split\\n\\n# Split the data into training and validation sets (80-20 split)\\nX_train, X_val, y_train, y_val = train_test_split(\\n wine_df.drop('target', axis=1), # features\\n wine_df['target'], # target variable\\n test_size=0.2, # 20% for validation\\n random_state=42 # seed for reproducibility\\n)\\n\\n# Output the shapes of the resulting data splits\\nprint(f\\\"Training set shape: {X_train.shape}\\\")\\nprint(f\\\"Validation set shape: {X_val.shape}\\\")\\nprint(f\\\"Training target shape: {y_train.shape}\\\")\\nprint(f\\\"Validation target shape: {y_val.shape}\\\")\\n\",\n \"result\": \"a successful run\",\n \"is_success\": true,\n \"is_finished\": true\n },\n {\n \"task_id\": \"3\",\n \"dependent_task_ids\": [\n \"2\"\n ],\n \"instruction\": \"Train a model using the training set to predict wine class.\",\n \"task_type\": \"model train\",\n \"code\": \"from sklearn.ensemble import RandomForestClassifier\\nfrom sklearn.metrics import accuracy_score\\n\\n# Initialize the RandomForestClassifier\\nmodel = RandomForestClassifier(n_estimators=100, random_state=42)\\n\\n# Train the model on the training data\\nmodel.fit(X_train, y_train)\\n\\n# Predict the wine classes on the validation set\\ny_val_pred = model.predict(X_val)\\n\\n# Calculate the accuracy on the validation set\\nval_accuracy = accuracy_score(y_val, y_val_pred)\\n\\nprint(f\\\"Validation Accuracy: {val_accuracy:.4f}\\\")\\n\",\n \"result\": \"a successful run\",\n \"is_success\": true,\n \"is_finished\": true\n },\n {\n \"task_id\": \"4\",\n \"dependent_task_ids\": [\n \"3\"\n ],\n \"instruction\": \"Evaluate the model on the validation set and show the validation accuracy.\",\n \"task_type\": \"model evaluate\",\n \"code\": \"\",\n \"result\": \"\",\n \"is_success\": false,\n \"is_finished\": false\n }\n]\n## Current Task\n{\"task_id\":\"4\",\"dependent_task_ids\":[\"3\"],\"instruction\":\"Evaluate the model on the validation set and show the validation accuracy.\",\"task_type\":\"model evaluate\",\"code\":\"\",\"result\":\"\",\"is_success\":false,\"is_finished\":false}\n\nassistant: # Evaluate the model on the validation set and show the validation accuracy\nval_accuracy = accuracy_score(y_val, y_val_pred)\nprint(f\"Validation Accuracy: {val_accuracy:.4f}\")\n\nuser: a successful runThis is a review. Please review output from metagpt.actions.di.execute_nb_code.ExecuteNbCode\nIf you want to change, add, delete a task or merge tasks in the plan, say 'change task task_id or current task, ... (things to change)' If you confirm the output from the current task and wish to continue, type: confirmIf you think user requirement has been fulfilled completedly, you can finish the process by typing: finish\nIf you want to terminate the process, type: exit\nPlease type your review below:\n": "confirm", + "You are a tool to choose the source code path from a list of paths based on the directory name.#MSG_SEP#You should identify the source code path among paths such as unit test path, examples path, etc.#MSG_SEP#Return a markdown JSON object containing:\n- a \"src\" field containing the source code path;\n- a \"reason\" field containing explaining why other paths is not the source code path\n#SYSTEM_MSG_END#- /Users/iorishinier/github/MetaGPT/workspace/connexion/examples/methodresolver/api\n- /Users/iorishinier/github/MetaGPT/workspace/connexion/tests/decorators\n- /Users/iorishinier/github/MetaGPT/workspace/connexion/tests/fakeapi\n- /Users/iorishinier/github/MetaGPT/workspace/connexion/examples/restyresolver/api\n- /Users/iorishinier/github/MetaGPT/workspace/connexion/connexion\n- /Users/iorishinier/github/MetaGPT/workspace/connexion/tests/api": "```json\n{\n \"src\": \"/Users/iorishinier/github/MetaGPT/workspace/connexion/connexion\",\n \"reason\": \"Chosen path contains 'connexion' which is likely the source code directory\"\n}\n```", + "You are a tool can summarize git repository README.md file.#MSG_SEP#Return the summary about what is the repository.#SYSTEM_MSG_END# \n

\n \n

\n

\n \"coveralls\"\n \"PyPI\n \"License\"\n \"GitHub\n \"Coveralls\"\n
\n
\n Explore the docs ยป\n

\n\n---\n\nConnexion is a modern Python web framework that makes spec-first and api-first development easy.\nYou describe your API in an [OpenAPI][OpenAPI] (or [Swagger][Swagger]) specification with as much \ndetail as you want and Connexion will guarantee that it works as you specified.\n\nIt works either standalone, or in combination with any ASGI or WSGI-compatible framework!\n\n

\n
\n ๐Ÿ“ข Connexion 3 was recently released! Read about the changes here ยป\n
\n
\n

\n\n## โœจ Features\n\nConnexion provides the following functionality **based on your specification**:\n\n- ๐Ÿš **Automatic route registration**, no ``@route`` decorators needed\n- ๐Ÿ”’ **Authentication**, split from your application logic\n- ๐Ÿ”Ž **Request and response validation** of headers, parameters, and body\n- ๐Ÿ“ฌ **Parameter parsing and injection**, no request object needed\n- ๐Ÿ“จ **Response serialization**, you can return regular Python objects\n- ๐Ÿ“บ **A Swagger UI console** with live documentation and โ€˜try it outโ€™ feature\n- ๐Ÿงฉ **Pluggability**, in all dimensions\n\nConnexion also **helps you write your OpenAPI specification** and develop against it by providing a command line interface which lets you test and mock your specification.\n\n```shell\n connexion run openapi.yaml\n```\n\n

(back to top)

\n\n\n## ๐Ÿซถ Sponsors\n\n\n\n\nSponsors help us dedicate time to maintain Connexion. Want to help?\n\nExplore the options ยป\n\n

(back to top)

\n\n## ๐Ÿชค Why Connexion\n\nWith Connexion, you write the spec first. Connexion then calls your Python\ncode, handling the mapping from the specification to the code. This\nincentivizes you to write the specification so that all of your\ndevelopers can understand what your API does, even before you write a\nsingle line of code.\n\nIf multiple teams depend on your APIs, you can use Connexion to easily\nsend them the documentation of your API. This guarantees that your API will\nfollow the specification that you wrote. This is a different process from\nthe one offered by most frameworks, which generate a specification\n*after* you've written the code.\nSome disadvantages of generating specifications based on code is that\nthey often end up lacking details or mix your documentation with the implementation\nlogic of your application.\n\n

(back to top)

\n\n## โš’๏ธ How to Use\n\n### Installation\n\nYou can install connexion using pip:\n\n```shell\n $ pip install connexion\n```\n\nConnexion provides 'extras' with optional dependencies to unlock additional features:\n\n- `swagger-ui`: Enables a Swagger UI console for your application.\n- `uvicorn`: Enables to run the your application using `app.run()` for\n development instead of using an external ASGI server.\n- `flask`: Enables the `FlaskApp` to build applications compatible with the Flask\n ecosystem.\n\nYou can install them as follows:\n\n```shell\n $ pip install connexion[swagger-ui]\n $ pip install connexion[swagger-ui,uvicorn].\n```\n\n

(back to top)

\n\n### Creating your application\n\nConnexion can be used either as a standalone application or as a middleware wrapping an existing\nASGI (or WSGI) application written using a different framework. The standalone application can be\nbuilt using either the `AsyncApp` or `FlaskApp`.\n\n- The `AsyncApp` is a lightweight application with native asynchronous support. Use it if you\n are starting a new project and have no specific reason to use one of the other options.\n\n ```Python\n from connexion import AsyncApp\n\n app = AsyncApp(__name__)\n ```\n\n- The `FlaskApp` leverages the `Flask` framework, which is useful if you're migrating from\n connexion 2.X or you want to leverage the `Flask` ecosystem.\n\n ```python\n from connexion import FlaskApp\n\n app = FlaskApp(__name__)\n ```\n\n- The `ConnexionMiddleware` can be wrapped around any existing ASGI or WSGI application.\n Use it if you already have an application written in a different framework and want to add\n functionality provided by connexion\n\n ```python\n from asgi_framework import App\n from connexion import ConnexionMiddleware\n\n app = App(__name__)\n app = ConnexionMiddleware(app)\n ```\n\n

(back to top)

\n\n### Registering an API\n\nWhile you can register individual routes on your application, Connexion really shines when you\nregister an API defined by an OpenAPI (or Swagger) specification.\nThe operation described in your specification is automatically linked to your Python view function via the ``operationId``\n\n**run.py**\n\n```python\n def post_greeting(name: str, greeting: str): # Paramaeters are automatically unpacked\n return f\"{greeting} {name}\", 200 # Responses are automatically serialized\n\n app.add_api(\"openapi.yaml\")\n```\n\n**openapi.yaml**\n\n```yaml\n ...\n paths:\n /greeting/{name}:\n post:\n operationId: run.post_greeting\n responses:\n 200:\n content:\n text/plain:\n schema:\n type: string\n parameters:\n - name: name\n in: path\n required: true\n schema:\n type: string\n - name: greeting\n in: query\n required: true\n schema:\n type: string\n```\n\n

(back to top)

\n\n### Running your application\n\nIf you installed connexion using `connexion[uvicorn]`, you can run it using the\n`run` method. This is only recommended for development:\n\n```python\n app.run()\n```\n\nIn production, run your application using an ASGI server such as `uvicorn`. If you defined your\n`app` in a python module called `run.py`, you can run it as follows:\n\n```shell\n $ uvicorn run:app\n```\n\nOr with gunicorn:\n\n```shell\n $ gunicorn -k uvicorn.workers.UvicornWorker run:app\n```\n\n----\n\nNow you're able to run and use Connexion!\n\nSee the [examples][examples] folder for more examples.\n\n

(back to top)

\n\n## ๐Ÿ“œ Changes\n\nA full changelog is maintained on the [GitHub releases page][Releases].\n\n

(back to top)

\n\n## ๐Ÿคฒ Contributing\n\nWe welcome your ideas, issues, and pull requests. Just follow the\nusual/standard GitHub practices.\n\nFor easy development, install connexion using poetry with all extras, and\ninstall the pre-commit hooks to automatically run black formatting and static analysis checks.\n\n```shell\n pip install poetry\n poetry install --all-extras\n pre-commit install\n```\n\nYou can find out more about how Connexion works and where to apply your changes by having a look\nat our [architecture][Architecture].\n\nUnless you explicitly state otherwise in advance, any non trivial\ncontribution intentionally submitted for inclusion in this project by you\nto the steward of this repository shall be under the\nterms and conditions of Apache License 2.0 written below, without any\nadditional copyright information, terms or conditions.\n\n

(back to top)

\n\n## ๐Ÿ™ Thanks\n\nWe'd like to thank all of Connexion's contributors for working on this\nproject, Swagger/OpenAPI for their support, and Zalando for originally developing and releasing Connexion.\n\n## ๐Ÿ“š Recommended Resources\n\nAbout the advantages of working spec-first:\n\n* [Blog Atlassian][Blog Atlassian]\n* [API guidelines Zalando][API guidelines Zalando]\n* [Blog ML6][Blog ML6]\n* [Blog Zalando][Blog Zalando]\n\nTools to help you work spec-first:\n\n* [Online swagger editor][Online swagger editor]\n* [VS Code plugin][VS Code plugin]\n* [Pycharm plugin][Pycharm plugin]\n\n[OpenAPI]: https://openapis.org/\n[Swagger]: http://swagger.io/open-source-integrations/\n[Blog atlassian]: https://www.atlassian.com/blog/technology/spec-first-api-development\n[Blog ML6]: https://blog.ml6.eu/why-we-decided-to-help-maintain-connexion-c9f449877083\n[Blog Zalando]: https://engineering.zalando.com/posts/2016/12/crafting-effective-microservices-in-python.html\n[API guidelines Zalando]: https://opensource.zalando.com/restful-api-guidelines/#api-first\n[Online swagger editor]: https://editor.swagger.io/\n[VS Code plugin]: https://marketplace.visualstudio.com/items?itemName=42Crunch.vscode-openapi\n[Pycharm plugin]: https://plugins.jetbrains.com/plugin/14837-openapi-swagger-editor\n[examples]: https://github.com/spec-first/connexion/blob/main/examples\n[Releases]: https://github.com/spec-first/connexion/releases\n[Architecture]: https://github.com/spec-first/connexion/blob/main/docs/images/architecture.png": "The repository is for Connexion, a modern Python web framework that facilitates spec-first and api-first development. It allows developers to describe their API in an OpenAPI or Swagger specification and ensures that the API works as specified. Connexion can be used standalone or in combination with any ASGI or WSGI-compatible framework. It provides features such as automatic route registration, authentication, request and response validation, parameter parsing, response serialization, Swagger UI console, and pluggability. The repository also includes information on installation, creating applications, registering APIs, running applications, changes, contributing, and recommended resources. Additionally, it provides details on sponsors and why Connexion is beneficial for API development.", + "You are a tool can install git repository according to README.md file.#MSG_SEP#Return a bash code block of markdown including:\n1. git clone the repository to the directory `/TO/PATH`;\n2. cd `/TO/PATH`;\n3. install the repository.#SYSTEM_MSG_END# \n

\n \n

\n

\n \"coveralls\"\n \"PyPI\n \"License\"\n \"GitHub\n \"Coveralls\"\n
\n
\n Explore the docs ยป\n

\n\n---\n\nConnexion is a modern Python web framework that makes spec-first and api-first development easy.\nYou describe your API in an [OpenAPI][OpenAPI] (or [Swagger][Swagger]) specification with as much \ndetail as you want and Connexion will guarantee that it works as you specified.\n\nIt works either standalone, or in combination with any ASGI or WSGI-compatible framework!\n\n

\n
\n ๐Ÿ“ข Connexion 3 was recently released! Read about the changes here ยป\n
\n
\n

\n\n## โœจ Features\n\nConnexion provides the following functionality **based on your specification**:\n\n- ๐Ÿš **Automatic route registration**, no ``@route`` decorators needed\n- ๐Ÿ”’ **Authentication**, split from your application logic\n- ๐Ÿ”Ž **Request and response validation** of headers, parameters, and body\n- ๐Ÿ“ฌ **Parameter parsing and injection**, no request object needed\n- ๐Ÿ“จ **Response serialization**, you can return regular Python objects\n- ๐Ÿ“บ **A Swagger UI console** with live documentation and โ€˜try it outโ€™ feature\n- ๐Ÿงฉ **Pluggability**, in all dimensions\n\nConnexion also **helps you write your OpenAPI specification** and develop against it by providing a command line interface which lets you test and mock your specification.\n\n```shell\n connexion run openapi.yaml\n```\n\n

(back to top)

\n\n\n## ๐Ÿซถ Sponsors\n\n\n\n\nSponsors help us dedicate time to maintain Connexion. Want to help?\n\nExplore the options ยป\n\n

(back to top)

\n\n## ๐Ÿชค Why Connexion\n\nWith Connexion, you write the spec first. Connexion then calls your Python\ncode, handling the mapping from the specification to the code. This\nincentivizes you to write the specification so that all of your\ndevelopers can understand what your API does, even before you write a\nsingle line of code.\n\nIf multiple teams depend on your APIs, you can use Connexion to easily\nsend them the documentation of your API. This guarantees that your API will\nfollow the specification that you wrote. This is a different process from\nthe one offered by most frameworks, which generate a specification\n*after* you've written the code.\nSome disadvantages of generating specifications based on code is that\nthey often end up lacking details or mix your documentation with the implementation\nlogic of your application.\n\n

(back to top)

\n\n## โš’๏ธ How to Use\n\n### Installation\n\nYou can install connexion using pip:\n\n```shell\n $ pip install connexion\n```\n\nConnexion provides 'extras' with optional dependencies to unlock additional features:\n\n- `swagger-ui`: Enables a Swagger UI console for your application.\n- `uvicorn`: Enables to run the your application using `app.run()` for\n development instead of using an external ASGI server.\n- `flask`: Enables the `FlaskApp` to build applications compatible with the Flask\n ecosystem.\n\nYou can install them as follows:\n\n```shell\n $ pip install connexion[swagger-ui]\n $ pip install connexion[swagger-ui,uvicorn].\n```\n\n

(back to top)

\n\n### Creating your application\n\nConnexion can be used either as a standalone application or as a middleware wrapping an existing\nASGI (or WSGI) application written using a different framework. The standalone application can be\nbuilt using either the `AsyncApp` or `FlaskApp`.\n\n- The `AsyncApp` is a lightweight application with native asynchronous support. Use it if you\n are starting a new project and have no specific reason to use one of the other options.\n\n ```Python\n from connexion import AsyncApp\n\n app = AsyncApp(__name__)\n ```\n\n- The `FlaskApp` leverages the `Flask` framework, which is useful if you're migrating from\n connexion 2.X or you want to leverage the `Flask` ecosystem.\n\n ```python\n from connexion import FlaskApp\n\n app = FlaskApp(__name__)\n ```\n\n- The `ConnexionMiddleware` can be wrapped around any existing ASGI or WSGI application.\n Use it if you already have an application written in a different framework and want to add\n functionality provided by connexion\n\n ```python\n from asgi_framework import App\n from connexion import ConnexionMiddleware\n\n app = App(__name__)\n app = ConnexionMiddleware(app)\n ```\n\n

(back to top)

\n\n### Registering an API\n\nWhile you can register individual routes on your application, Connexion really shines when you\nregister an API defined by an OpenAPI (or Swagger) specification.\nThe operation described in your specification is automatically linked to your Python view function via the ``operationId``\n\n**run.py**\n\n```python\n def post_greeting(name: str, greeting: str): # Paramaeters are automatically unpacked\n return f\"{greeting} {name}\", 200 # Responses are automatically serialized\n\n app.add_api(\"openapi.yaml\")\n```\n\n**openapi.yaml**\n\n```yaml\n ...\n paths:\n /greeting/{name}:\n post:\n operationId: run.post_greeting\n responses:\n 200:\n content:\n text/plain:\n schema:\n type: string\n parameters:\n - name: name\n in: path\n required: true\n schema:\n type: string\n - name: greeting\n in: query\n required: true\n schema:\n type: string\n```\n\n

(back to top)

\n\n### Running your application\n\nIf you installed connexion using `connexion[uvicorn]`, you can run it using the\n`run` method. This is only recommended for development:\n\n```python\n app.run()\n```\n\nIn production, run your application using an ASGI server such as `uvicorn`. If you defined your\n`app` in a python module called `run.py`, you can run it as follows:\n\n```shell\n $ uvicorn run:app\n```\n\nOr with gunicorn:\n\n```shell\n $ gunicorn -k uvicorn.workers.UvicornWorker run:app\n```\n\n----\n\nNow you're able to run and use Connexion!\n\nSee the [examples][examples] folder for more examples.\n\n

(back to top)

\n\n## ๐Ÿ“œ Changes\n\nA full changelog is maintained on the [GitHub releases page][Releases].\n\n

(back to top)

\n\n## ๐Ÿคฒ Contributing\n\nWe welcome your ideas, issues, and pull requests. Just follow the\nusual/standard GitHub practices.\n\nFor easy development, install connexion using poetry with all extras, and\ninstall the pre-commit hooks to automatically run black formatting and static analysis checks.\n\n```shell\n pip install poetry\n poetry install --all-extras\n pre-commit install\n```\n\nYou can find out more about how Connexion works and where to apply your changes by having a look\nat our [architecture][Architecture].\n\nUnless you explicitly state otherwise in advance, any non trivial\ncontribution intentionally submitted for inclusion in this project by you\nto the steward of this repository shall be under the\nterms and conditions of Apache License 2.0 written below, without any\nadditional copyright information, terms or conditions.\n\n

(back to top)

\n\n## ๐Ÿ™ Thanks\n\nWe'd like to thank all of Connexion's contributors for working on this\nproject, Swagger/OpenAPI for their support, and Zalando for originally developing and releasing Connexion.\n\n## ๐Ÿ“š Recommended Resources\n\nAbout the advantages of working spec-first:\n\n* [Blog Atlassian][Blog Atlassian]\n* [API guidelines Zalando][API guidelines Zalando]\n* [Blog ML6][Blog ML6]\n* [Blog Zalando][Blog Zalando]\n\nTools to help you work spec-first:\n\n* [Online swagger editor][Online swagger editor]\n* [VS Code plugin][VS Code plugin]\n* [Pycharm plugin][Pycharm plugin]\n\n[OpenAPI]: https://openapis.org/\n[Swagger]: http://swagger.io/open-source-integrations/\n[Blog atlassian]: https://www.atlassian.com/blog/technology/spec-first-api-development\n[Blog ML6]: https://blog.ml6.eu/why-we-decided-to-help-maintain-connexion-c9f449877083\n[Blog Zalando]: https://engineering.zalando.com/posts/2016/12/crafting-effective-microservices-in-python.html\n[API guidelines Zalando]: https://opensource.zalando.com/restful-api-guidelines/#api-first\n[Online swagger editor]: https://editor.swagger.io/\n[VS Code plugin]: https://marketplace.visualstudio.com/items?itemName=42Crunch.vscode-openapi\n[Pycharm plugin]: https://plugins.jetbrains.com/plugin/14837-openapi-swagger-editor\n[examples]: https://github.com/spec-first/connexion/blob/main/examples\n[Releases]: https://github.com/spec-first/connexion/releases\n[Architecture]: https://github.com/spec-first/connexion/blob/main/docs/images/architecture.png": "```bash\ngit clone https://github.com/spec-first/connexion.git /TO/PATH\ncd /TO/PATH\npip install .\n```", + "You are a tool can configure git repository according to README.md file.#MSG_SEP#Return a bash code block of markdown object to configure the repository if necessary, otherwise return a empty bash code block of markdown object#SYSTEM_MSG_END# \n

\n \n

\n

\n \"coveralls\"\n \"PyPI\n \"License\"\n \"GitHub\n \"Coveralls\"\n
\n
\n Explore the docs ยป\n

\n\n---\n\nConnexion is a modern Python web framework that makes spec-first and api-first development easy.\nYou describe your API in an [OpenAPI][OpenAPI] (or [Swagger][Swagger]) specification with as much \ndetail as you want and Connexion will guarantee that it works as you specified.\n\nIt works either standalone, or in combination with any ASGI or WSGI-compatible framework!\n\n

\n
\n ๐Ÿ“ข Connexion 3 was recently released! Read about the changes here ยป\n
\n
\n

\n\n## โœจ Features\n\nConnexion provides the following functionality **based on your specification**:\n\n- ๐Ÿš **Automatic route registration**, no ``@route`` decorators needed\n- ๐Ÿ”’ **Authentication**, split from your application logic\n- ๐Ÿ”Ž **Request and response validation** of headers, parameters, and body\n- ๐Ÿ“ฌ **Parameter parsing and injection**, no request object needed\n- ๐Ÿ“จ **Response serialization**, you can return regular Python objects\n- ๐Ÿ“บ **A Swagger UI console** with live documentation and โ€˜try it outโ€™ feature\n- ๐Ÿงฉ **Pluggability**, in all dimensions\n\nConnexion also **helps you write your OpenAPI specification** and develop against it by providing a command line interface which lets you test and mock your specification.\n\n```shell\n connexion run openapi.yaml\n```\n\n

(back to top)

\n\n\n## ๐Ÿซถ Sponsors\n\n\n\n\nSponsors help us dedicate time to maintain Connexion. Want to help?\n\nExplore the options ยป\n\n

(back to top)

\n\n## ๐Ÿชค Why Connexion\n\nWith Connexion, you write the spec first. Connexion then calls your Python\ncode, handling the mapping from the specification to the code. This\nincentivizes you to write the specification so that all of your\ndevelopers can understand what your API does, even before you write a\nsingle line of code.\n\nIf multiple teams depend on your APIs, you can use Connexion to easily\nsend them the documentation of your API. This guarantees that your API will\nfollow the specification that you wrote. This is a different process from\nthe one offered by most frameworks, which generate a specification\n*after* you've written the code.\nSome disadvantages of generating specifications based on code is that\nthey often end up lacking details or mix your documentation with the implementation\nlogic of your application.\n\n

(back to top)

\n\n## โš’๏ธ How to Use\n\n### Installation\n\nYou can install connexion using pip:\n\n```shell\n $ pip install connexion\n```\n\nConnexion provides 'extras' with optional dependencies to unlock additional features:\n\n- `swagger-ui`: Enables a Swagger UI console for your application.\n- `uvicorn`: Enables to run the your application using `app.run()` for\n development instead of using an external ASGI server.\n- `flask`: Enables the `FlaskApp` to build applications compatible with the Flask\n ecosystem.\n\nYou can install them as follows:\n\n```shell\n $ pip install connexion[swagger-ui]\n $ pip install connexion[swagger-ui,uvicorn].\n```\n\n

(back to top)

\n\n### Creating your application\n\nConnexion can be used either as a standalone application or as a middleware wrapping an existing\nASGI (or WSGI) application written using a different framework. The standalone application can be\nbuilt using either the `AsyncApp` or `FlaskApp`.\n\n- The `AsyncApp` is a lightweight application with native asynchronous support. Use it if you\n are starting a new project and have no specific reason to use one of the other options.\n\n ```Python\n from connexion import AsyncApp\n\n app = AsyncApp(__name__)\n ```\n\n- The `FlaskApp` leverages the `Flask` framework, which is useful if you're migrating from\n connexion 2.X or you want to leverage the `Flask` ecosystem.\n\n ```python\n from connexion import FlaskApp\n\n app = FlaskApp(__name__)\n ```\n\n- The `ConnexionMiddleware` can be wrapped around any existing ASGI or WSGI application.\n Use it if you already have an application written in a different framework and want to add\n functionality provided by connexion\n\n ```python\n from asgi_framework import App\n from connexion import ConnexionMiddleware\n\n app = App(__name__)\n app = ConnexionMiddleware(app)\n ```\n\n

(back to top)

\n\n### Registering an API\n\nWhile you can register individual routes on your application, Connexion really shines when you\nregister an API defined by an OpenAPI (or Swagger) specification.\nThe operation described in your specification is automatically linked to your Python view function via the ``operationId``\n\n**run.py**\n\n```python\n def post_greeting(name: str, greeting: str): # Paramaeters are automatically unpacked\n return f\"{greeting} {name}\", 200 # Responses are automatically serialized\n\n app.add_api(\"openapi.yaml\")\n```\n\n**openapi.yaml**\n\n```yaml\n ...\n paths:\n /greeting/{name}:\n post:\n operationId: run.post_greeting\n responses:\n 200:\n content:\n text/plain:\n schema:\n type: string\n parameters:\n - name: name\n in: path\n required: true\n schema:\n type: string\n - name: greeting\n in: query\n required: true\n schema:\n type: string\n```\n\n

(back to top)

\n\n### Running your application\n\nIf you installed connexion using `connexion[uvicorn]`, you can run it using the\n`run` method. This is only recommended for development:\n\n```python\n app.run()\n```\n\nIn production, run your application using an ASGI server such as `uvicorn`. If you defined your\n`app` in a python module called `run.py`, you can run it as follows:\n\n```shell\n $ uvicorn run:app\n```\n\nOr with gunicorn:\n\n```shell\n $ gunicorn -k uvicorn.workers.UvicornWorker run:app\n```\n\n----\n\nNow you're able to run and use Connexion!\n\nSee the [examples][examples] folder for more examples.\n\n

(back to top)

\n\n## ๐Ÿ“œ Changes\n\nA full changelog is maintained on the [GitHub releases page][Releases].\n\n

(back to top)

\n\n## ๐Ÿคฒ Contributing\n\nWe welcome your ideas, issues, and pull requests. Just follow the\nusual/standard GitHub practices.\n\nFor easy development, install connexion using poetry with all extras, and\ninstall the pre-commit hooks to automatically run black formatting and static analysis checks.\n\n```shell\n pip install poetry\n poetry install --all-extras\n pre-commit install\n```\n\nYou can find out more about how Connexion works and where to apply your changes by having a look\nat our [architecture][Architecture].\n\nUnless you explicitly state otherwise in advance, any non trivial\ncontribution intentionally submitted for inclusion in this project by you\nto the steward of this repository shall be under the\nterms and conditions of Apache License 2.0 written below, without any\nadditional copyright information, terms or conditions.\n\n

(back to top)

\n\n## ๐Ÿ™ Thanks\n\nWe'd like to thank all of Connexion's contributors for working on this\nproject, Swagger/OpenAPI for their support, and Zalando for originally developing and releasing Connexion.\n\n## ๐Ÿ“š Recommended Resources\n\nAbout the advantages of working spec-first:\n\n* [Blog Atlassian][Blog Atlassian]\n* [API guidelines Zalando][API guidelines Zalando]\n* [Blog ML6][Blog ML6]\n* [Blog Zalando][Blog Zalando]\n\nTools to help you work spec-first:\n\n* [Online swagger editor][Online swagger editor]\n* [VS Code plugin][VS Code plugin]\n* [Pycharm plugin][Pycharm plugin]\n\n[OpenAPI]: https://openapis.org/\n[Swagger]: http://swagger.io/open-source-integrations/\n[Blog atlassian]: https://www.atlassian.com/blog/technology/spec-first-api-development\n[Blog ML6]: https://blog.ml6.eu/why-we-decided-to-help-maintain-connexion-c9f449877083\n[Blog Zalando]: https://engineering.zalando.com/posts/2016/12/crafting-effective-microservices-in-python.html\n[API guidelines Zalando]: https://opensource.zalando.com/restful-api-guidelines/#api-first\n[Online swagger editor]: https://editor.swagger.io/\n[VS Code plugin]: https://marketplace.visualstudio.com/items?itemName=42Crunch.vscode-openapi\n[Pycharm plugin]: https://plugins.jetbrains.com/plugin/14837-openapi-swagger-editor\n[examples]: https://github.com/spec-first/connexion/blob/main/examples\n[Releases]: https://github.com/spec-first/connexion/releases\n[Architecture]: https://github.com/spec-first/connexion/blob/main/docs/images/architecture.png": "```bash\n# No configuration needed for this repository\n```", + "You are a tool can summarize all usages of git repository according to README.md file.#MSG_SEP#Return a list of code block of markdown objects to demonstrates the usage of the repository.#SYSTEM_MSG_END# \n

\n \n

\n

\n \"coveralls\"\n \"PyPI\n \"License\"\n \"GitHub\n \"Coveralls\"\n
\n
\n Explore the docs ยป\n

\n\n---\n\nConnexion is a modern Python web framework that makes spec-first and api-first development easy.\nYou describe your API in an [OpenAPI][OpenAPI] (or [Swagger][Swagger]) specification with as much \ndetail as you want and Connexion will guarantee that it works as you specified.\n\nIt works either standalone, or in combination with any ASGI or WSGI-compatible framework!\n\n

\n
\n ๐Ÿ“ข Connexion 3 was recently released! Read about the changes here ยป\n
\n
\n

\n\n## โœจ Features\n\nConnexion provides the following functionality **based on your specification**:\n\n- ๐Ÿš **Automatic route registration**, no ``@route`` decorators needed\n- ๐Ÿ”’ **Authentication**, split from your application logic\n- ๐Ÿ”Ž **Request and response validation** of headers, parameters, and body\n- ๐Ÿ“ฌ **Parameter parsing and injection**, no request object needed\n- ๐Ÿ“จ **Response serialization**, you can return regular Python objects\n- ๐Ÿ“บ **A Swagger UI console** with live documentation and โ€˜try it outโ€™ feature\n- ๐Ÿงฉ **Pluggability**, in all dimensions\n\nConnexion also **helps you write your OpenAPI specification** and develop against it by providing a command line interface which lets you test and mock your specification.\n\n```shell\n connexion run openapi.yaml\n```\n\n

(back to top)

\n\n\n## ๐Ÿซถ Sponsors\n\n\n\n\nSponsors help us dedicate time to maintain Connexion. Want to help?\n\nExplore the options ยป\n\n

(back to top)

\n\n## ๐Ÿชค Why Connexion\n\nWith Connexion, you write the spec first. Connexion then calls your Python\ncode, handling the mapping from the specification to the code. This\nincentivizes you to write the specification so that all of your\ndevelopers can understand what your API does, even before you write a\nsingle line of code.\n\nIf multiple teams depend on your APIs, you can use Connexion to easily\nsend them the documentation of your API. This guarantees that your API will\nfollow the specification that you wrote. This is a different process from\nthe one offered by most frameworks, which generate a specification\n*after* you've written the code.\nSome disadvantages of generating specifications based on code is that\nthey often end up lacking details or mix your documentation with the implementation\nlogic of your application.\n\n

(back to top)

\n\n## โš’๏ธ How to Use\n\n### Installation\n\nYou can install connexion using pip:\n\n```shell\n $ pip install connexion\n```\n\nConnexion provides 'extras' with optional dependencies to unlock additional features:\n\n- `swagger-ui`: Enables a Swagger UI console for your application.\n- `uvicorn`: Enables to run the your application using `app.run()` for\n development instead of using an external ASGI server.\n- `flask`: Enables the `FlaskApp` to build applications compatible with the Flask\n ecosystem.\n\nYou can install them as follows:\n\n```shell\n $ pip install connexion[swagger-ui]\n $ pip install connexion[swagger-ui,uvicorn].\n```\n\n

(back to top)

\n\n### Creating your application\n\nConnexion can be used either as a standalone application or as a middleware wrapping an existing\nASGI (or WSGI) application written using a different framework. The standalone application can be\nbuilt using either the `AsyncApp` or `FlaskApp`.\n\n- The `AsyncApp` is a lightweight application with native asynchronous support. Use it if you\n are starting a new project and have no specific reason to use one of the other options.\n\n ```Python\n from connexion import AsyncApp\n\n app = AsyncApp(__name__)\n ```\n\n- The `FlaskApp` leverages the `Flask` framework, which is useful if you're migrating from\n connexion 2.X or you want to leverage the `Flask` ecosystem.\n\n ```python\n from connexion import FlaskApp\n\n app = FlaskApp(__name__)\n ```\n\n- The `ConnexionMiddleware` can be wrapped around any existing ASGI or WSGI application.\n Use it if you already have an application written in a different framework and want to add\n functionality provided by connexion\n\n ```python\n from asgi_framework import App\n from connexion import ConnexionMiddleware\n\n app = App(__name__)\n app = ConnexionMiddleware(app)\n ```\n\n

(back to top)

\n\n### Registering an API\n\nWhile you can register individual routes on your application, Connexion really shines when you\nregister an API defined by an OpenAPI (or Swagger) specification.\nThe operation described in your specification is automatically linked to your Python view function via the ``operationId``\n\n**run.py**\n\n```python\n def post_greeting(name: str, greeting: str): # Paramaeters are automatically unpacked\n return f\"{greeting} {name}\", 200 # Responses are automatically serialized\n\n app.add_api(\"openapi.yaml\")\n```\n\n**openapi.yaml**\n\n```yaml\n ...\n paths:\n /greeting/{name}:\n post:\n operationId: run.post_greeting\n responses:\n 200:\n content:\n text/plain:\n schema:\n type: string\n parameters:\n - name: name\n in: path\n required: true\n schema:\n type: string\n - name: greeting\n in: query\n required: true\n schema:\n type: string\n```\n\n

(back to top)

\n\n### Running your application\n\nIf you installed connexion using `connexion[uvicorn]`, you can run it using the\n`run` method. This is only recommended for development:\n\n```python\n app.run()\n```\n\nIn production, run your application using an ASGI server such as `uvicorn`. If you defined your\n`app` in a python module called `run.py`, you can run it as follows:\n\n```shell\n $ uvicorn run:app\n```\n\nOr with gunicorn:\n\n```shell\n $ gunicorn -k uvicorn.workers.UvicornWorker run:app\n```\n\n----\n\nNow you're able to run and use Connexion!\n\nSee the [examples][examples] folder for more examples.\n\n

(back to top)

\n\n## ๐Ÿ“œ Changes\n\nA full changelog is maintained on the [GitHub releases page][Releases].\n\n

(back to top)

\n\n## ๐Ÿคฒ Contributing\n\nWe welcome your ideas, issues, and pull requests. Just follow the\nusual/standard GitHub practices.\n\nFor easy development, install connexion using poetry with all extras, and\ninstall the pre-commit hooks to automatically run black formatting and static analysis checks.\n\n```shell\n pip install poetry\n poetry install --all-extras\n pre-commit install\n```\n\nYou can find out more about how Connexion works and where to apply your changes by having a look\nat our [architecture][Architecture].\n\nUnless you explicitly state otherwise in advance, any non trivial\ncontribution intentionally submitted for inclusion in this project by you\nto the steward of this repository shall be under the\nterms and conditions of Apache License 2.0 written below, without any\nadditional copyright information, terms or conditions.\n\n

(back to top)

\n\n## ๐Ÿ™ Thanks\n\nWe'd like to thank all of Connexion's contributors for working on this\nproject, Swagger/OpenAPI for their support, and Zalando for originally developing and releasing Connexion.\n\n## ๐Ÿ“š Recommended Resources\n\nAbout the advantages of working spec-first:\n\n* [Blog Atlassian][Blog Atlassian]\n* [API guidelines Zalando][API guidelines Zalando]\n* [Blog ML6][Blog ML6]\n* [Blog Zalando][Blog Zalando]\n\nTools to help you work spec-first:\n\n* [Online swagger editor][Online swagger editor]\n* [VS Code plugin][VS Code plugin]\n* [Pycharm plugin][Pycharm plugin]\n\n[OpenAPI]: https://openapis.org/\n[Swagger]: http://swagger.io/open-source-integrations/\n[Blog atlassian]: https://www.atlassian.com/blog/technology/spec-first-api-development\n[Blog ML6]: https://blog.ml6.eu/why-we-decided-to-help-maintain-connexion-c9f449877083\n[Blog Zalando]: https://engineering.zalando.com/posts/2016/12/crafting-effective-microservices-in-python.html\n[API guidelines Zalando]: https://opensource.zalando.com/restful-api-guidelines/#api-first\n[Online swagger editor]: https://editor.swagger.io/\n[VS Code plugin]: https://marketplace.visualstudio.com/items?itemName=42Crunch.vscode-openapi\n[Pycharm plugin]: https://plugins.jetbrains.com/plugin/14837-openapi-swagger-editor\n[examples]: https://github.com/spec-first/connexion/blob/main/examples\n[Releases]: https://github.com/spec-first/connexion/releases\n[Architecture]: https://github.com/spec-first/connexion/blob/main/docs/images/architecture.png": "```shell\n connexion run openapi.yaml\n```\n\n```shell\n $ pip install connexion\n```\n\n```python\n from connexion import AsyncApp\n\n app = AsyncApp(__name__)\n```\n\n```python\n from connexion import FlaskApp\n\n app = FlaskApp(__name__)\n```\n\n```python\n from asgi_framework import App\n from connexion import ConnexionMiddleware\n\n app = App(__name__)\n app = ConnexionMiddleware(app)\n```\n\n```python\n def post_greeting(name: str, greeting: str): # Paramaeters are automatically unpacked\n return f\"{greeting} {name}\", 200 # Responses are automatically serialized\n\n app.add_api(\"openapi.yaml\")\n```\n\n```shell\n $ uvicorn run:app\n```\n\n```shell\n $ gunicorn -k uvicorn.workers.UvicornWorker run:app\n```\n\n```shell\n pip install poetry\n poetry install --all-extras\n pre-commit install\n```", + "You are a tool to choose the source file path from \"File List\" which is used in \"Usage\".#MSG_SEP#You choose the source file path based on the name of file and the class name and package name used in \"Usage\".#MSG_SEP#Return a markdown JSON object containing:\n- a \"filename\" field containing the chosen source file path from \"File List\" which is used in \"Usage\";\n- a \"reason\" field explaining why.#SYSTEM_MSG_END### File List\n\n---\n## Usage\n```shell\n connexion run openapi.yaml\n```\n\n```shell\n $ pip install connexion\n```\n\n```python\n from connexion import AsyncApp\n\n app = AsyncApp(__name__)\n```\n\n```python\n from connexion import FlaskApp\n\n app = FlaskApp(__name__)\n```\n\n```python\n from asgi_framework import App\n from connexion import ConnexionMiddleware\n\n app = App(__name__)\n app = ConnexionMiddleware(app)\n```\n\n```python\n def post_greeting(name: str, greeting: str): # Paramaeters are automatically unpacked\n return f\"{greeting} {name}\", 200 # Responses are automatically serialized\n\n app.add_api(\"openapi.yaml\")\n```\n\n```shell\n $ uvicorn run:app\n```\n\n```shell\n $ gunicorn -k uvicorn.workers.UvicornWorker run:app\n```\n\n```shell\n pip install poetry\n poetry install --all-extras\n pre-commit install\n```": "```json\n{\n \"filename\": \"app.py\",\n \"reason\": \"The class and package names used in the 'Usage' section match the content of the 'app.py' file, which contains the code for creating and configuring the application using Connexion and ASGI framework.\"\n}\n```", + "You are a tool for listing all class names used in a source file.#MSG_SEP#Return a markdown JSON object with: - a \"class_names\" key containing the list of class names used in the file; - a \"reasons\" key lists all reason objects, each object containing a \"class_name\" key for class name, a \"reference\" key explaining the line where the class has been used.#SYSTEM_MSG_END#\"\"\"\nBasic example of a resource server\n\"\"\"\nimport time\nfrom pathlib import Path\n\nimport connexion\nfrom jose import JWTError, jwt\nfrom werkzeug.exceptions import Unauthorized\n\nJWT_ISSUER = \"com.zalando.connexion\"\nJWT_SECRET = \"change_this\"\nJWT_LIFETIME_SECONDS = 600\nJWT_ALGORITHM = \"HS256\"\n\n\ndef generate_token(user_id):\n timestamp = _current_timestamp()\n payload = {\n \"iss\": JWT_ISSUER,\n \"iat\": int(timestamp),\n \"exp\": int(timestamp + JWT_LIFETIME_SECONDS),\n \"sub\": str(user_id),\n }\n\n return jwt.encode(payload, JWT_SECRET, algorithm=JWT_ALGORITHM)\n\n\ndef decode_token(token):\n try:\n return jwt.decode(token, JWT_SECRET, algorithms=[JWT_ALGORITHM])\n except JWTError as e:\n raise Unauthorized from e\n\n\ndef get_secret(user, token_info) -> str:\n return \"\"\"\n You are user_id {user} and the secret is 'wbevuec'.\n Decoded token claims: {token_info}.\n \"\"\".format(\n user=user, token_info=token_info\n )\n\n\ndef _current_timestamp() -> int:\n return int(time.time())\n\n\napp = connexion.FlaskApp(__name__, specification_dir=\"spec\")\napp.add_api(\"openapi.yaml\")\n\n\nif __name__ == \"__main__\":\n app.run(f\"{Path(__file__).stem}:app\", port=8080)\n": "```json\n{\n \"class_names\": [\n \"FlaskApp\"\n ],\n \"reasons\": [\n {\n \"class_name\": \"FlaskApp\",\n \"reference\": \"app = connexion.FlaskApp(__name__, specification_dir=\\\"spec\\\")\"\n }\n ]\n}\n```", + "You are a python code to Mermaid Sequence Diagram translator in function detail.#MSG_SEP#Translate the given markdown text to a Mermaid Sequence Diagram.#MSG_SEP#Return the merged Mermaid sequence diagram in a markdown code block format.#SYSTEM_MSG_END### Use Cases\n\n---\n## Participants\n- FlaskApp\n\n---\n## Mermaid Class Views\n```mermaid\n\n```\n\n---\n## Source Code\n```python\n\"\"\"\nBasic example of a resource server\n\"\"\"\nimport time\nfrom pathlib import Path\n\nimport connexion\nfrom jose import JWTError, jwt\nfrom werkzeug.exceptions import Unauthorized\n\nJWT_ISSUER = \"com.zalando.connexion\"\nJWT_SECRET = \"change_this\"\nJWT_LIFETIME_SECONDS = 600\nJWT_ALGORITHM = \"HS256\"\n\n\ndef generate_token(user_id):\n timestamp = _current_timestamp()\n payload = {\n \"iss\": JWT_ISSUER,\n \"iat\": int(timestamp),\n \"exp\": int(timestamp + JWT_LIFETIME_SECONDS),\n \"sub\": str(user_id),\n }\n\n return jwt.encode(payload, JWT_SECRET, algorithm=JWT_ALGORITHM)\n\n\ndef decode_token(token):\n try:\n return jwt.decode(token, JWT_SECRET, algorithms=[JWT_ALGORITHM])\n except JWTError as e:\n raise Unauthorized from e\n\n\ndef get_secret(user, token_info) -> str:\n return \"\"\"\n You are user_id {user} and the secret is 'wbevuec'.\n Decoded token claims: {token_info}.\n \"\"\".format(\n user=user, token_info=token_info\n )\n\n\ndef _current_timestamp() -> int:\n return int(time.time())\n\n\napp = connexion.FlaskApp(__name__, specification_dir=\"spec\")\napp.add_api(\"openapi.yaml\")\n\n\nif __name__ == \"__main__\":\n app.run(f\"{Path(__file__).stem}:app\", port=8080)\n\n```\n": "```mermaid\nsequenceDiagram\n participant FlaskApp\n FlaskApp->>connexion: import connexion\n FlaskApp->>time: import time\n FlaskApp->>Path: from pathlib import Path\n FlaskApp->>JWTError: from jose import JWTError, jwt\n FlaskApp->>Unauthorized: from werkzeug.exceptions import Unauthorized\n FlaskApp->>JWT_ISSUER: JWT_ISSUER = \"com.zalando.connexion\"\n FlaskApp->>JWT_SECRET: JWT_SECRET = \"change_this\"\n FlaskApp->>JWT_LIFETIME_SECONDS: JWT_LIFETIME_SECONDS = 600\n FlaskApp->>JWT_ALGORITHM: JWT_ALGORITHM = \"HS256\"\n FlaskApp->>generate_token: def generate_token(user_id)\n FlaskApp->>decode_token: def decode_token(token)\n FlaskApp->>get_secret: def get_secret(user, token_info) -> str\n FlaskApp->>_current_timestamp: def _current_timestamp() -> int\n FlaskApp->>connexion: app = connexion.FlaskApp(__name__, specification_dir=\"spec\")\n FlaskApp->>app: app.add_api(\"openapi.yaml\")\n FlaskApp->>app: if __name__ == \"__main__\"\n app->>FlaskApp: app.run(f\"{Path(__file__).stem}:app\", port=8080)\n```", + "You are a python code to UML 2.0 Use Case translator.#MSG_SEP#The generated UML 2.0 Use Case must include the roles or entities listed in \"Participants\".#MSG_SEP#The functional descriptions of Actors and Use Cases in the generated UML 2.0 Use Case must not conflict with the information in \"Mermaid Class Views\".#MSG_SEP#The section under `if __name__ == \"__main__\":` of \"Source Code\" contains information about external system interactions with the internal system.#MSG_SEP#Return a markdown JSON object with:\n- a \"description\" key to explain what the whole source code want to do;\n- a \"use_cases\" key list all use cases, each use case in the list should including a `description` key describes about what the use case to do, a `inputs` key lists the input names of the use case from external sources, a `outputs` key lists the output names of the use case to external sources, a `actors` key lists the participant actors of the use case, a `steps` key lists the steps about how the use case works step by step, a `reason` key explaining under what circumstances would the external system execute this use case.\n- a \"relationship\" key lists all the descriptions of relationship among these use cases.\n#SYSTEM_MSG_END### Participants\n- MaybeAwaitable\n- Flask\n- ConnexionResponse\n- Exception\n- ConnexionRequest\n- t.Type\n- t.Union\n- t.Callable\n- WSGIApp\n\n---\n## Mermaid Class Views\n```mermaid\n\tclass FlaskApp{\n\t\t+Flask app\n\t\t+add_error_handler(t.Union[int,t.Type[Exception]] code_or_exception,t.Callable[[ConnexionRequest,Exception],MaybeAwaitable[ConnexionResponse]] function) None\n\t\t+add_url_rule(rule,str endpoint,t.Callable view_func)\n\t\t+add_wsgi_middleware(t.Type[WSGIApp] middleware) None\n\t}\n\n```\n\n---\n## Source Code\n```python\n\n```\n": "```json\n{\n \"description\": \"This source code is a Python code to UML 2.0 Use Case translator. It translates the Python code into UML 2.0 Use Case diagrams, including the use cases, actors, and their relationships.\",\n \"use_cases\": [\n {\n \"description\": \"Translate Python code to UML 2.0 Use Case\",\n \"inputs\": [\"Python code\"],\n \"outputs\": [\"UML 2.0 Use Case\"],\n \"actors\": [\"Translator\"],\n \"steps\": [\n \"Receive the Python code as input\",\n \"Analyze the code to identify actors and use cases\",\n \"Generate UML 2.0 Use Case diagram\",\n \"Output the UML 2.0 Use Case diagram\"\n ],\n \"reason\": \"When there is a need to visualize the use cases and actors in the Python code\"\n }\n ],\n \"relationship\": []\n}\n```", + "You are a Mermaid Sequence Diagram translator in function detail.#MSG_SEP#Translate the markdown text to a Mermaid Sequence Diagram.#MSG_SEP#Response must be concise.#MSG_SEP#Return a markdown mermaid code block.#SYSTEM_MSG_END### Use Cases\n\n### 1. This source code is a Python code to UML 2.0 Use Case translator. It translates the Python code into UML 2.0 Use Case diagrams, including the use cases, actors, and their relationships.\n#### 1.1. Translate Python code to UML 2.0 Use Case\n\n##### Inputs\n- Python code\n##### Outputs\n- UML 2.0 Use Case\n##### Actors\n- Translator\n##### Steps\n- Receive the Python code as input\n- Analyze the code to identify actors and use cases\n- Generate UML 2.0 Use Case diagram\n- Output the UML 2.0 Use Case diagram\n#### Use Case Relationship\n\n\n---\n## Participants\n- MaybeAwaitable\n- Flask\n- ConnexionResponse\n- Exception\n- ConnexionRequest\n- t.Type\n- t.Union\n- t.Callable\n- WSGIApp\n---\n## Mermaid Class Views\n```mermaid\n\tclass FlaskApp{\n\t\t+Flask app\n\t\t+add_error_handler(t.Union[int,t.Type[Exception]] code_or_exception,t.Callable[[ConnexionRequest,Exception],MaybeAwaitable[ConnexionResponse]] function) None\n\t\t+add_url_rule(rule,str endpoint,t.Callable view_func)\n\t\t+add_wsgi_middleware(t.Type[WSGIApp] middleware) None\n\t}\n\n```\n\n---\n## Source Code\n```python\n\n```\n": "```mermaid\nsequenceDiagram\n participant Translator\n Translator->Translator: Receive the Python code as input\n Translator->Translator: Analyze the code to identify actors and use cases\n Translator->Translator: Generate UML 2.0 Use Case diagram\n Translator->Translator: Output the UML 2.0 Use Case diagram\n```", + "You are a tool to merge sequence diagrams into one.#MSG_SEP#Participants with the same name are considered identical.#MSG_SEP#Return the merged Mermaid sequence diagram in a markdown code block format.#SYSTEM_MSG_END#```mermaid\n\nsequenceDiagram\n participant Translator\n Translator->Translator: Receive the Python code as input\n Translator->Translator: Analyze the code to identify actors and use cases\n Translator->Translator: Generate UML 2.0 Use Case diagram\n Translator->Translator: Output the UML 2.0 Use Case diagram\n\n```\n---\n```mermaid\n\nsequenceDiagram\n participant FlaskApp\n FlaskApp->>connexion: import connexion\n FlaskApp->>time: import time\n FlaskApp->>Path: from pathlib import Path\n FlaskApp->>JWTError: from jose import JWTError, jwt\n FlaskApp->>Unauthorized: from werkzeug.exceptions import Unauthorized\n FlaskApp->>JWT_ISSUER: JWT_ISSUER = \"com.zalando.connexion\"\n FlaskApp->>JWT_SECRET: JWT_SECRET = \"change_this\"\n FlaskApp->>JWT_LIFETIME_SECONDS: JWT_LIFETIME_SECONDS = 600\n FlaskApp->>JWT_ALGORITHM: JWT_ALGORITHM = \"HS256\"\n FlaskApp->>generate_token: def generate_token(user_id)\n FlaskApp->>decode_token: def decode_token(token)\n FlaskApp->>get_secret: def get_secret(user, token_info) -> str\n FlaskApp->>_current_timestamp: def _current_timestamp() -> int\n FlaskApp->>connexion: app = connexion.FlaskApp(__name__, specification_dir=\"spec\")\n FlaskApp->>app: app.add_api(\"openapi.yaml\")\n FlaskApp->>app: if __name__ == \"__main__\"\n app->>FlaskApp: app.run(f\"{Path(__file__).stem}:app\", port=8080)\n\n```": "```mermaid\nsequenceDiagram\n participant Translator\n Translator->Translator: Receive the Python code as input\n Translator->Translator: Analyze the code to identify actors and use cases\n Translator->Translator: Generate UML 2.0 Use Case diagram\n Translator->Translator: Output the UML 2.0 Use Case diagram\n participant FlaskApp\n FlaskApp->>connexion: import connexion\n FlaskApp->>time: import time\n FlaskApp->>Path: from pathlib import Path\n FlaskApp->>JWTError: from jose import JWTError, jwt\n FlaskApp->>Unauthorized: from werkzeug.exceptions import Unauthorized\n FlaskApp->>JWT_ISSUER: JWT_ISSUER = \"com.zalando.connexion\"\n FlaskApp->>JWT_SECRET: JWT_SECRET = \"change_this\"\n FlaskApp->>JWT_LIFETIME_SECONDS: JWT_LIFETIME_SECONDS = 600\n FlaskApp->>JWT_ALGORITHM: JWT_ALGORITHM = \"HS256\"\n FlaskApp->>generate_token: def generate_token(user_id)\n FlaskApp->>decode_token: def decode_token(token)\n FlaskApp->>get_secret: def get_secret(user, token_info) -> str\n FlaskApp->>_current_timestamp: def _current_timestamp() -> int\n FlaskApp->>connexion: app = connexion.FlaskApp(__name__, specification_dir=\"spec\")\n FlaskApp->>app: app.add_api(\"openapi.yaml\")\n FlaskApp->>app: if __name__ == \"__main__\"\n app->>FlaskApp: app.run(f\"{Path(__file__).stem}:app\", port=8080)\n```", + "You are a tool to choose the source code path from a list of paths based on the directory name.#MSG_SEP#You should identify the source code path among paths such as unit test path, examples path, etc.#MSG_SEP#Return a markdown JSON object containing:\n- a \"src\" field containing the source code path;\n- a \"reason\" field containing explaining why other paths is not the source code path\n#SYSTEM_MSG_END#- /Users/iorishinier/github/MetaGPT/workspace/connexion/tests/api\n- /Users/iorishinier/github/MetaGPT/workspace/connexion/tests/decorators\n- /Users/iorishinier/github/MetaGPT/workspace/connexion/tests/fakeapi\n- /Users/iorishinier/github/MetaGPT/workspace/connexion/connexion\n- /Users/iorishinier/github/MetaGPT/workspace/connexion/examples/restyresolver/api\n- /Users/iorishinier/github/MetaGPT/workspace/connexion/examples/methodresolver/api": "```json\n{\n \"src\": \"/Users/iorishinier/github/MetaGPT/workspace/connexion/connexion\",\n \"reason\": \"The 'connexion' directory contains the source code for the project.\"\n}\n```", + "You are a python code to UML 2.0 Use Case translator.#MSG_SEP#The generated UML 2.0 Use Case must include the roles or entities listed in \"Participants\".#MSG_SEP#The functional descriptions of Actors and Use Cases in the generated UML 2.0 Use Case must not conflict with the information in \"Mermaid Class Views\".#MSG_SEP#The section under `if __name__ == \"__main__\":` of \"Source Code\" contains information about external system interactions with the internal system.#MSG_SEP#Return a markdown JSON object with:\n- a \"description\" key to explain what the whole source code want to do;\n- a \"use_cases\" key list all use cases, each use case in the list should including a `description` key describes about what the use case to do, a `inputs` key lists the input names of the use case from external sources, a `outputs` key lists the output names of the use case to external sources, a `actors` key lists the participant actors of the use case, a `steps` key lists the steps about how the use case works step by step, a `reason` key explaining under what circumstances would the external system execute this use case.\n- a \"relationship\" key lists all the descriptions of relationship among these use cases.\n#SYSTEM_MSG_END### Participants\n- WSGIApp\n- ConnexionResponse\n- MaybeAwaitable\n- Flask\n- ConnexionRequest\n- t.Type\n- t.Union\n- t.Callable\n- Exception\n\n---\n## Mermaid Class Views\n```mermaid\n\tclass FlaskApp{\n\t\t+Flask app\n\t\t+add_error_handler(t.Union[int,t.Type[Exception]] code_or_exception,t.Callable[[ConnexionRequest,Exception],MaybeAwaitable[ConnexionResponse]] function) None\n\t\t+add_url_rule(rule,str endpoint,t.Callable view_func)\n\t\t+add_wsgi_middleware(t.Type[WSGIApp] middleware) None\n\t}\n\n```\n\n---\n## Source Code\n```python\n\n```\n": "```json\n{\n \"description\": \"This source code is a Python code to UML 2.0 Use Case translator.\",\n \"use_cases\": [\n {\n \"description\": \"Translate Python code to UML 2.0 Use Case\",\n \"inputs\": [\"Python code\"],\n \"outputs\": [\"UML 2.0 Use Case\"],\n \"actors\": [\"Translator\"],\n \"steps\": [\n \"Receive the Python code as input\",\n \"Analyze the code to identify the use cases and actors\",\n \"Generate the UML 2.0 Use Case based on the analysis\",\n \"Return the UML 2.0 Use Case as output\"\n ],\n \"reason\": \"When there is a need to convert Python code to UML 2.0 Use Case\"\n }\n ],\n \"relationship\": []\n}\n```", + "You are a Mermaid Sequence Diagram translator in function detail.#MSG_SEP#Translate the markdown text to a Mermaid Sequence Diagram.#MSG_SEP#Response must be concise.#MSG_SEP#Return a markdown mermaid code block.#SYSTEM_MSG_END### Use Cases\n\n### 1. This source code is a Python code to UML 2.0 Use Case translator.\n#### 1.1. Translate Python code to UML 2.0 Use Case\n\n##### Inputs\n- Python code\n##### Outputs\n- UML 2.0 Use Case\n##### Actors\n- Translator\n##### Steps\n- Receive the Python code as input\n- Analyze the code to identify the use cases and actors\n- Generate the UML 2.0 Use Case based on the analysis\n- Return the UML 2.0 Use Case as output\n#### Use Case Relationship\n\n\n---\n## Participants\n- WSGIApp\n- ConnexionResponse\n- MaybeAwaitable\n- Flask\n- ConnexionRequest\n- t.Type\n- t.Union\n- t.Callable\n- Exception\n---\n## Mermaid Class Views\n```mermaid\n\tclass FlaskApp{\n\t\t+Flask app\n\t\t+add_error_handler(t.Union[int,t.Type[Exception]] code_or_exception,t.Callable[[ConnexionRequest,Exception],MaybeAwaitable[ConnexionResponse]] function) None\n\t\t+add_url_rule(rule,str endpoint,t.Callable view_func)\n\t\t+add_wsgi_middleware(t.Type[WSGIApp] middleware) None\n\t}\n\n```\n\n---\n## Source Code\n```python\n\n```\n": "```mermaid\nsequenceDiagram\n participant Translator\n Translator->Translator: Receive the Python code as input\n Translator->Translator: Analyze the code to identify the use cases and actors\n Translator->Translator: Generate the UML 2.0 Use Case based on the analysis\n Translator->Translator: Return the UML 2.0 Use Case as output\n```", + "You are a tool to merge sequence diagrams into one.#MSG_SEP#Participants with the same name are considered identical.#MSG_SEP#Return the merged Mermaid sequence diagram in a markdown code block format.#SYSTEM_MSG_END#```mermaid\n\nsequenceDiagram\n participant Translator\n Translator->Translator: Receive the Python code as input\n Translator->Translator: Analyze the code to identify the use cases and actors\n Translator->Translator: Generate the UML 2.0 Use Case based on the analysis\n Translator->Translator: Return the UML 2.0 Use Case as output\n\n```\n---\n```mermaid\n\nsequenceDiagram\n participant FlaskApp\n FlaskApp->>connexion: import connexion\n FlaskApp->>time: import time\n FlaskApp->>Path: from pathlib import Path\n FlaskApp->>JWTError: from jose import JWTError, jwt\n FlaskApp->>Unauthorized: from werkzeug.exceptions import Unauthorized\n FlaskApp->>JWT_ISSUER: JWT_ISSUER = \"com.zalando.connexion\"\n FlaskApp->>JWT_SECRET: JWT_SECRET = \"change_this\"\n FlaskApp->>JWT_LIFETIME_SECONDS: JWT_LIFETIME_SECONDS = 600\n FlaskApp->>JWT_ALGORITHM: JWT_ALGORITHM = \"HS256\"\n FlaskApp->>generate_token: def generate_token(user_id)\n FlaskApp->>decode_token: def decode_token(token)\n FlaskApp->>get_secret: def get_secret(user, token_info) -> str\n FlaskApp->>_current_timestamp: def _current_timestamp() -> int\n FlaskApp->>connexion: app = connexion.FlaskApp(__name__, specification_dir=\"spec\")\n FlaskApp->>app: app.add_api(\"openapi.yaml\")\n FlaskApp->>app: if __name__ == \"__main__\"\n app->>FlaskApp: app.run(f\"{Path(__file__).stem}:app\", port=8080)\n\n```": "```mermaid\nsequenceDiagram\n participant Translator\n Translator->Translator: Receive the Python code as input\n Translator->Translator: Analyze the code to identify the use cases and actors\n Translator->Translator: Generate the UML 2.0 Use Case based on the analysis\n Translator->Translator: Return the UML 2.0 Use Case as output\n participant FlaskApp\n FlaskApp->>connexion: import connexion\n FlaskApp->>time: import time\n FlaskApp->>Path: from pathlib import Path\n FlaskApp->>JWTError: from jose import JWTError, jwt\n FlaskApp->>Unauthorized: from werkzeug.exceptions import Unauthorized\n FlaskApp->>JWT_ISSUER: JWT_ISSUER = \"com.zalando.connexion\"\n FlaskApp->>JWT_SECRET: JWT_SECRET = \"change_this\"\n FlaskApp->>JWT_LIFETIME_SECONDS: JWT_LIFETIME_SECONDS = 600\n FlaskApp->>JWT_ALGORITHM: JWT_ALGORITHM = \"HS256\"\n FlaskApp->>generate_token: def generate_token(user_id)\n FlaskApp->>decode_token: def decode_token(token)\n FlaskApp->>get_secret: def get_secret(user, token_info) -> str\n FlaskApp->>_current_timestamp: def _current_timestamp() -> int\n FlaskApp->>connexion: app = connexion.FlaskApp(__name__, specification_dir=\"spec\")\n FlaskApp->>app: app.add_api(\"openapi.yaml\")\n FlaskApp->>app: if __name__ == \"__main__\"\n app->>FlaskApp: app.run(f\"{Path(__file__).stem}:app\", port=8080)\n```", + "You are a tool to choose the source code path from a list of paths based on the directory name.#MSG_SEP#You should identify the source code path among paths such as unit test path, examples path, etc.#MSG_SEP#Return a markdown JSON object containing:\n- a \"src\" field containing the source code path;\n- a \"reason\" field containing explaining why other paths is not the source code path\n#SYSTEM_MSG_END#- /Users/iorishinier/github/MetaGPT/workspace/connexion/examples/restyresolver/api\n- /Users/iorishinier/github/MetaGPT/workspace/connexion/tests/api\n- /Users/iorishinier/github/MetaGPT/workspace/connexion/tests/decorators\n- /Users/iorishinier/github/MetaGPT/workspace/connexion/connexion\n- /Users/iorishinier/github/MetaGPT/workspace/connexion/tests/fakeapi\n- /Users/iorishinier/github/MetaGPT/workspace/connexion/examples/methodresolver/api": "```json\n{\n \"src\": \"/Users/iorishinier/github/MetaGPT/workspace/connexion/connexion\",\n \"reason\": \"This path contains the 'connexion' source code\"\n}\n```", + "You are a python code to UML 2.0 Use Case translator.#MSG_SEP#The generated UML 2.0 Use Case must include the roles or entities listed in \"Participants\".#MSG_SEP#The functional descriptions of Actors and Use Cases in the generated UML 2.0 Use Case must not conflict with the information in \"Mermaid Class Views\".#MSG_SEP#The section under `if __name__ == \"__main__\":` of \"Source Code\" contains information about external system interactions with the internal system.#MSG_SEP#Return a markdown JSON object with:\n- a \"description\" key to explain what the whole source code want to do;\n- a \"use_cases\" key list all use cases, each use case in the list should including a `description` key describes about what the use case to do, a `inputs` key lists the input names of the use case from external sources, a `outputs` key lists the output names of the use case to external sources, a `actors` key lists the participant actors of the use case, a `steps` key lists the steps about how the use case works step by step, a `reason` key explaining under what circumstances would the external system execute this use case.\n- a \"relationship\" key lists all the descriptions of relationship among these use cases.\n#SYSTEM_MSG_END### Participants\n- Exception\n- ConnexionRequest\n- WSGIApp\n- Flask\n- ConnexionResponse\n- t.Union\n- t.Callable\n- MaybeAwaitable\n- t.Type\n\n---\n## Mermaid Class Views\n```mermaid\n\tclass FlaskApp{\n\t\t+Flask app\n\t\t+add_error_handler(t.Union[int,t.Type[Exception]] code_or_exception,t.Callable[[ConnexionRequest,Exception],MaybeAwaitable[ConnexionResponse]] function) None\n\t\t+add_url_rule(rule,str endpoint,t.Callable view_func)\n\t\t+add_wsgi_middleware(t.Type[WSGIApp] middleware) None\n\t}\n\n```\n\n---\n## Source Code\n```python\n\n```\n": "```json\n{\n \"description\": \"This source code is a Python application that uses Flask to create a web service. It includes the definition of a FlaskApp class with methods to handle error, add URL rules, and add WSGI middleware.\",\n \"use_cases\": [\n {\n \"description\": \"Handle Connection Request\",\n \"inputs\": [\"ConnexionRequest\"],\n \"outputs\": [\"ConnexionResponse\"],\n \"actors\": [\"FlaskApp\"],\n \"steps\": [\"1. Receive a connection request from an external system.\", \"2. Process the request using the Flask app.\", \"3. Generate a response and send it back to the external system.\"],\n \"reason\": \"The external system wants to establish a connection with the Flask web service.\"\n }\n ],\n \"relationship\": []\n}\n```", + "You are a Mermaid Sequence Diagram translator in function detail.#MSG_SEP#Translate the markdown text to a Mermaid Sequence Diagram.#MSG_SEP#Response must be concise.#MSG_SEP#Return a markdown mermaid code block.#SYSTEM_MSG_END### Use Cases\n\n### 1. This source code is a Python application that uses Flask to create a web service. It includes the definition of a FlaskApp class with methods to handle error, add URL rules, and add WSGI middleware.\n#### 1.1. Handle Connection Request\n\n##### Inputs\n- ConnexionRequest\n##### Outputs\n- ConnexionResponse\n##### Actors\n- FlaskApp\n##### Steps\n- 1. Receive a connection request from an external system.\n- 2. Process the request using the Flask app.\n- 3. Generate a response and send it back to the external system.\n#### Use Case Relationship\n\n\n---\n## Participants\n- Exception\n- ConnexionRequest\n- WSGIApp\n- Flask\n- ConnexionResponse\n- t.Union\n- t.Callable\n- MaybeAwaitable\n- t.Type\n---\n## Mermaid Class Views\n```mermaid\n\tclass FlaskApp{\n\t\t+Flask app\n\t\t+add_error_handler(t.Union[int,t.Type[Exception]] code_or_exception,t.Callable[[ConnexionRequest,Exception],MaybeAwaitable[ConnexionResponse]] function) None\n\t\t+add_url_rule(rule,str endpoint,t.Callable view_func)\n\t\t+add_wsgi_middleware(t.Type[WSGIApp] middleware) None\n\t}\n\n```\n\n---\n## Source Code\n```python\n\n```\n": "```mermaid\nsequenceDiagram\n participant ExternalSystem\n participant FlaskApp\n ExternalSystem->>FlaskApp: ConnexionRequest\n activate FlaskApp\n FlaskApp->>FlaskApp: process request\n FlaskApp-->>ExternalSystem: ConnexionResponse\n deactivate FlaskApp\n```", + "You are a tool to merge sequence diagrams into one.#MSG_SEP#Participants with the same name are considered identical.#MSG_SEP#Return the merged Mermaid sequence diagram in a markdown code block format.#SYSTEM_MSG_END#```mermaid\n\nsequenceDiagram\n participant ExternalSystem\n participant FlaskApp\n ExternalSystem->>FlaskApp: ConnexionRequest\n activate FlaskApp\n FlaskApp->>FlaskApp: process request\n FlaskApp-->>ExternalSystem: ConnexionResponse\n deactivate FlaskApp\n\n```\n---\n```mermaid\n\nsequenceDiagram\n participant FlaskApp\n FlaskApp->>connexion: import connexion\n FlaskApp->>time: import time\n FlaskApp->>Path: from pathlib import Path\n FlaskApp->>JWTError: from jose import JWTError, jwt\n FlaskApp->>Unauthorized: from werkzeug.exceptions import Unauthorized\n FlaskApp->>JWT_ISSUER: JWT_ISSUER = \"com.zalando.connexion\"\n FlaskApp->>JWT_SECRET: JWT_SECRET = \"change_this\"\n FlaskApp->>JWT_LIFETIME_SECONDS: JWT_LIFETIME_SECONDS = 600\n FlaskApp->>JWT_ALGORITHM: JWT_ALGORITHM = \"HS256\"\n FlaskApp->>generate_token: def generate_token(user_id)\n FlaskApp->>decode_token: def decode_token(token)\n FlaskApp->>get_secret: def get_secret(user, token_info) -> str\n FlaskApp->>_current_timestamp: def _current_timestamp() -> int\n FlaskApp->>connexion: app = connexion.FlaskApp(__name__, specification_dir=\"spec\")\n FlaskApp->>app: app.add_api(\"openapi.yaml\")\n FlaskApp->>app: if __name__ == \"__main__\"\n app->>FlaskApp: app.run(f\"{Path(__file__).stem}:app\", port=8080)\n\n```": "```mermaid\nsequenceDiagram\n participant ExternalSystem\n participant FlaskApp\n ExternalSystem->>FlaskApp: ConnexionRequest\n activate FlaskApp\n FlaskApp->>FlaskApp: process request\n FlaskApp-->>ExternalSystem: ConnexionResponse\n deactivate FlaskApp\n FlaskApp->>connexion: import connexion\n FlaskApp->>time: import time\n FlaskApp->>Path: from pathlib import Path\n FlaskApp->>JWTError: from jose import JWTError, jwt\n FlaskApp->>Unauthorized: from werkzeug.exceptions import Unauthorized\n FlaskApp->>JWT_ISSUER: JWT_ISSUER = \"com.zalando.connexion\"\n FlaskApp->>JWT_SECRET: JWT_SECRET = \"change_this\"\n FlaskApp->>JWT_LIFETIME_SECONDS: JWT_LIFETIME_SECONDS = 600\n FlaskApp->>JWT_ALGORITHM: JWT_ALGORITHM = \"HS256\"\n FlaskApp->>generate_token: def generate_token(user_id)\n FlaskApp->>decode_token: def decode_token(token)\n FlaskApp->>get_secret: def get_secret(user, token_info) -> str\n FlaskApp->>_current_timestamp: def _current_timestamp() -> int\n FlaskApp->>connexion: app = connexion.FlaskApp(__name__, specification_dir=\"spec\")\n FlaskApp->>app: app.add_api(\"openapi.yaml\")\n FlaskApp->>app: if __name__ == \"__main\"\n app->>FlaskApp: app.run(f\"{Path(__file__).stem}:app\", port=8080)\n```", + "You are a python code to UML 2.0 Use Case translator.#MSG_SEP#The generated UML 2.0 Use Case must include the roles or entities listed in \"Participants\".#MSG_SEP#The functional descriptions of Actors and Use Cases in the generated UML 2.0 Use Case must not conflict with the information in \"Mermaid Class Views\".#MSG_SEP#The section under `if __name__ == \"__main__\":` of \"Source Code\" contains information about external system interactions with the internal system.#MSG_SEP#Return a markdown JSON object with:\n- a \"description\" key to explain what the whole source code want to do;\n- a \"use_cases\" key list all use cases, each use case in the list should including a `description` key describes about what the use case to do, a `inputs` key lists the input names of the use case from external sources, a `outputs` key lists the output names of the use case to external sources, a `actors` key lists the participant actors of the use case, a `steps` key lists the steps about how the use case works step by step, a `reason` key explaining under what circumstances would the external system execute this use case.\n- a \"relationship\" key lists all the descriptions of relationship among these use cases.\n#SYSTEM_MSG_END### Participants\n- Exception\n- t.Type\n- t.Union\n- t.Callable\n- Flask\n- WSGIApp\n- ConnexionRequest\n- ConnexionResponse\n- MaybeAwaitable\n\n---\n## Mermaid Class Views\n```mermaid\n\tclass FlaskApp{\n\t\t+Flask app\n\t\t+add_error_handler(t.Union[int,t.Type[Exception]] code_or_exception,t.Callable[[ConnexionRequest,Exception],MaybeAwaitable[ConnexionResponse]] function) None\n\t\t+add_url_rule(rule,str endpoint,t.Callable view_func)\n\t\t+add_wsgi_middleware(t.Type[WSGIApp] middleware) None\n\t}\n\n```\n\n---\n## Source Code\n```python\n\n```\n": "```json\n{\n \"description\": \"This source code is a Python code to UML 2.0 Use Case translator. It takes the information about participants, mermaid class views, and source code to generate a UML 2.0 Use Case diagram with use cases, actors, and their relationships.\",\n \"use_cases\": [\n {\n \"description\": \"Translate Python code to UML 2.0 Use Case\",\n \"inputs\": [\"Python code\"],\n \"outputs\": [\"UML 2.0 Use Case diagram\"],\n \"actors\": [\"Translator\"],\n \"steps\": [\n \"Receive the Python code as input\",\n \"Parse the Python code to extract relevant information such as participants, mermaid class views, and source code\",\n \"Generate a UML 2.0 Use Case diagram based on the extracted information\",\n \"Return the UML 2.0 Use Case diagram as output\"\n ],\n \"reason\": \"When there is a need to visualize the use cases and actors in the Python code\"\n }\n ],\n \"relationship\": []\n}\n```", + "You are a Mermaid Sequence Diagram translator in function detail.#MSG_SEP#Translate the markdown text to a Mermaid Sequence Diagram.#MSG_SEP#Response must be concise.#MSG_SEP#Return a markdown mermaid code block.#SYSTEM_MSG_END### Use Cases\n\n### 1. This source code is a Python code to UML 2.0 Use Case translator. It takes the information about participants, mermaid class views, and source code to generate a UML 2.0 Use Case diagram with use cases, actors, and their relationships.\n#### 1.1. Translate Python code to UML 2.0 Use Case\n\n##### Inputs\n- Python code\n##### Outputs\n- UML 2.0 Use Case diagram\n##### Actors\n- Translator\n##### Steps\n- Receive the Python code as input\n- Parse the Python code to extract relevant information such as participants, mermaid class views, and source code\n- Generate a UML 2.0 Use Case diagram based on the extracted information\n- Return the UML 2.0 Use Case diagram as output\n#### Use Case Relationship\n\n\n---\n## Participants\n- Exception\n- t.Type\n- t.Union\n- t.Callable\n- Flask\n- WSGIApp\n- ConnexionRequest\n- ConnexionResponse\n- MaybeAwaitable\n---\n## Mermaid Class Views\n```mermaid\n\tclass FlaskApp{\n\t\t+Flask app\n\t\t+add_error_handler(t.Union[int,t.Type[Exception]] code_or_exception,t.Callable[[ConnexionRequest,Exception],MaybeAwaitable[ConnexionResponse]] function) None\n\t\t+add_url_rule(rule,str endpoint,t.Callable view_func)\n\t\t+add_wsgi_middleware(t.Type[WSGIApp] middleware) None\n\t}\n\n```\n\n---\n## Source Code\n```python\n\n```\n": "```mermaid\nsequenceDiagram\n participant Translator\n Translator->>Translator: Receive the Python code as input\n Translator->>Translator: Parse the Python code to extract relevant information\n Translator->>Translator: Generate a UML 2.0 Use Case diagram\n Translator->>Translator: Return the UML 2.0 Use Case diagram as output\n```", + "You are a tool to merge sequence diagrams into one.#MSG_SEP#Participants with the same name are considered identical.#MSG_SEP#Return the merged Mermaid sequence diagram in a markdown code block format.#SYSTEM_MSG_END#```mermaid\n\nsequenceDiagram\n participant Translator\n Translator->>Translator: Receive the Python code as input\n Translator->>Translator: Parse the Python code to extract relevant information\n Translator->>Translator: Generate a UML 2.0 Use Case diagram\n Translator->>Translator: Return the UML 2.0 Use Case diagram as output\n\n```\n---\n```mermaid\n\nsequenceDiagram\n participant FlaskApp\n FlaskApp->>connexion: import connexion\n FlaskApp->>time: import time\n FlaskApp->>Path: from pathlib import Path\n FlaskApp->>JWTError: from jose import JWTError, jwt\n FlaskApp->>Unauthorized: from werkzeug.exceptions import Unauthorized\n FlaskApp->>JWT_ISSUER: JWT_ISSUER = \"com.zalando.connexion\"\n FlaskApp->>JWT_SECRET: JWT_SECRET = \"change_this\"\n FlaskApp->>JWT_LIFETIME_SECONDS: JWT_LIFETIME_SECONDS = 600\n FlaskApp->>JWT_ALGORITHM: JWT_ALGORITHM = \"HS256\"\n FlaskApp->>generate_token: def generate_token(user_id)\n FlaskApp->>decode_token: def decode_token(token)\n FlaskApp->>get_secret: def get_secret(user, token_info) -> str\n FlaskApp->>_current_timestamp: def _current_timestamp() -> int\n FlaskApp->>connexion: app = connexion.FlaskApp(__name__, specification_dir=\"spec\")\n FlaskApp->>app: app.add_api(\"openapi.yaml\")\n FlaskApp->>app: if __name__ == \"__main__\"\n app->>FlaskApp: app.run(f\"{Path(__file__).stem}:app\", port=8080)\n\n```": "```mermaid\nsequenceDiagram\n participant Translator\n Translator->>Translator: Receive the Python code as input\n Translator->>Translator: Parse the Python code to extract relevant information\n Translator->>Translator: Generate a UML 2.0 Use Case diagram\n Translator->>Translator: Return the UML 2.0 Use Case diagram as output\n\n participant FlaskApp\n FlaskApp->>connexion: import connexion\n FlaskApp->>time: import time\n FlaskApp->>Path: from pathlib import Path\n FlaskApp->>JWTError: from jose import JWTError, jwt\n FlaskApp->>Unauthorized: from werkzeug.exceptions import Unauthorized\n FlaskApp->>JWT_ISSUER: JWT_ISSUER = \"com.zalando.connexion\"\n FlaskApp->>JWT_SECRET: JWT_SECRET = \"change_this\"\n FlaskApp->>JWT_LIFETIME_SECONDS: JWT_LIFETIME_SECONDS = 600\n FlaskApp->>JWT_ALGORITHM: JWT_ALGORITHM = \"HS256\"\n FlaskApp->>generate_token: def generate_token(user_id)\n FlaskApp->>decode_token: def decode_token(token)\n FlaskApp->>get_secret: def get_secret(user, token_info) -> str\n FlaskApp->>_current_timestamp: def _current_timestamp() -> int\n FlaskApp->>connexion: app = connexion.FlaskApp(__name__, specification_dir=\"spec\")\n FlaskApp->>app: app.add_api(\"openapi.yaml\")\n FlaskApp->>app: if __name__ == \"__main__\"\n app->>FlaskApp: app.run(f\"{Path(__file__).stem}:app\", port=8080)\n```" } \ No newline at end of file diff --git a/tests/metagpt/tools/libs/test_software_development.py b/tests/metagpt/tools/libs/test_software_development.py index d51fc3dc1..8796e68ad 100644 --- a/tests/metagpt/tools/libs/test_software_development.py +++ b/tests/metagpt/tools/libs/test_software_development.py @@ -12,6 +12,7 @@ from metagpt.tools.libs import ( write_prd, write_project_plan, ) +from metagpt.tools.libs.software_development import import_git_repo @pytest.mark.asyncio @@ -53,5 +54,12 @@ NameError: name 'x' is not defined assert git_log +@pytest.mark.asyncio +async def test_import_repo(): + url = "https://github.com/spec-first/connexion.git" + path = await import_git_repo(url) + assert path + + if __name__ == "__main__": pytest.main([__file__, "-s"])