Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

rm yaml, add docstring

yzlin4938896dd826
diff --git a/.gitignore b/.gitignore
index ae0a17b45..6bc67fa61 100644
--- a/.gitignore
+++ b/.gitignore
@@ -178,3 +178,4 @@ cov.xml
*.faiss
*-structure.csv
*-structure.json
+metagpt/tools/schemas
\ No newline at end of file
diff --git a/metagpt/tools/libs/gpt_v_generator.py b/metagpt/tools/libs/gpt_v_generator.py
index 6a620f7e8..63fda3e81 100644
--- a/metagpt/tools/libs/gpt_v_generator.py
+++ b/metagpt/tools/libs/gpt_v_generator.py
@@ -30,9 +30,18 @@ As the design pays tribute to large companies, sometimes it is normal for some c
Now, please generate the corresponding webpage code including HTML, CSS and JavaScript:"""
-@register_tool(tool_type=ToolTypes.IMAGE2WEBPAGE.type_name)
+@register_tool(
+ tool_type=ToolTypes.IMAGE2WEBPAGE.type_name, include_functions=["__init__", "generate_webpages", "save_webpages"]
+)
class GPTvGenerator:
+ """Class for generating webpages at once.
+
+ This class provides methods to generate webpages including all code (HTML, CSS, and JavaScript) based on an image.
+ It utilizes a vision model to analyze the layout from an image and generate webpage codes accordingly.
+ """
+
def __init__(self):
+ """Initialize GPTvGenerator class with default values from the configuration."""
from metagpt.config2 import config
self.api_key = config.llm.api_key
@@ -41,15 +50,42 @@ class GPTvGenerator:
self.max_tokens = config.vision_max_tokens
def analyze_layout(self, image_path):
+ """Analyze the layout of the given image and return the result.
+
+ This is a helper method to generate a layout description based on the image.
+
+ Args:
+ image_path (str): Path of the image to analyze.
+
+ Returns:
+ str: The layout analysis result.
+ """
return self.get_result(image_path, ANALYZE_LAYOUT_PROMPT)
def generate_webpages(self, image_path):
+ """Generate webpages including all code (HTML, CSS, and JavaScript) in one go based on the image.
+
+ Args:
+ image_path (str): The path of the image file.
+
+ Returns:
+ str: Generated webpages content.
+ """
layout = self.analyze_layout(image_path)
prompt = GENERATE_PROMPT + "\n\n # Context\n The layout information of the sketch image is: \n" + layout
result = self.get_result(image_path, prompt)
return result
def get_result(self, image_path, prompt):
+ """Get the result from the vision model based on the given image path and prompt.
+
+ Args:
+ image_path (str): Path of the image to analyze.
+ prompt (str): Prompt to use for the analysis.
+
+ Returns:
+ str: The model's response as a string.
+ """
base64_image = self.encode_image(image_path)
headers = {"Content-Type": "application/json", "Authorization": f"Bearer {self.api_key}"}
payload = {
@@ -74,11 +110,28 @@ class GPTvGenerator:
@staticmethod
def encode_image(image_path):
+ """Encode the image at the given path to a base64 string.
+
+ Args:
+ image_path (str): Path of the image to encode.
+
+ Returns:
+ str: The base64 encoded string of the image.
+ """
with open(image_path, "rb") as image_file:
return base64.b64encode(image_file.read()).decode("utf-8")
@staticmethod
def save_webpages(image_path, webpages) -> Path:
+ """Save webpages including all code (HTML, CSS, and JavaScript) at once.
+
+ Args:
+ image_path (str): The path of the image file.
+ webpages (str): The generated webpages content.
+
+ Returns:
+ Path: The path of the saved webpages.
+ """
# 在workspace目录下,创建一个名为下webpages的文件夹,用于存储html、css和js文件
webpages_path = DEFAULT_WORKSPACE_ROOT / "webpages" / Path(image_path).stem
os.makedirs(webpages_path, exist_ok=True)
diff --git a/metagpt/tools/libs/sd_engine.py b/metagpt/tools/libs/sd_engine.py
index 6fb16993e..6229a60e3 100644
--- a/metagpt/tools/libs/sd_engine.py
+++ b/metagpt/tools/libs/sd_engine.py
@@ -53,10 +53,22 @@ payload = {
default_negative_prompt = "(easynegative:0.8),black, dark,Low resolution"
-@register_tool(tool_type=ToolTypes.STABLE_DIFFUSION.type_name)
+@register_tool(
+ tool_type=ToolTypes.STABLE_DIFFUSION.type_name,
+ include_functions=["__init__", "simple_run_t2i", "run_t2i", "construct_payload", "save"],
+)
class SDEngine:
+ """Generate image using stable diffusion model.
+
+ This class provides methods to interact with a stable diffusion service to generate images based on text inputs.
+ """
+
def __init__(self, sd_url=""):
- # Initialize the SDEngine with configuration
+ """Initialize the SDEngine instance with configuration.
+
+ Args:
+ sd_url (str, optional): URL of the stable diffusion service. Defaults to "".
+ """
self.sd_url = sd_url
self.sd_t2i_url = f"{self.sd_url}/sdapi/v1/txt2img"
# Define default payload settings for SD API
@@ -71,7 +83,18 @@ class SDEngine:
height=512,
sd_model="galaxytimemachinesGTM_photoV20",
):
- # Configure the payload with provided inputs
+ """Modify and set the API parameters for image generation.
+
+ Args:
+ prompt (str): Text input for image generation.
+ negtive_prompt (str, optional): Text input for negative prompts. Defaults to None.
+ width (int, optional): Width of the generated image in pixels. Defaults to 512.
+ height (int, optional): Height of the generated image in pixels. Defaults to 512.
+ sd_model (str, optional): The model to use for image generation. Defaults to "galaxytimemachinesGTM_photoV20".
+
+ Returns:
+ dict: Updated parameters for the stable diffusion API.
+ """
self.payload["prompt"] = prompt
self.payload["negative_prompt"] = negtive_prompt
self.payload["width"] = width
@@ -81,12 +104,27 @@ class SDEngine:
return self.payload
def save(self, imgs, save_name=""):
+ """Save generated images to the output directory.
+
+ Args:
+ imgs (str): Generated images.
+ save_name (str, optional): Output image name. Default is empty.
+ """
save_dir = SOURCE_ROOT / SD_OUTPUT_FILE_REPO
if not save_dir.exists():
save_dir.mkdir(parents=True, exist_ok=True)
batch_decode_base64_to_image(imgs, str(save_dir), save_name=save_name)
def simple_run_t2i(self, payload: dict, auto_save: bool = True):
+ """Run the stable diffusion API for multiple prompts, calling the stable diffusion API to generate images.
+
+ Args:
+ payload (dict): Dictionary of input parameters for the stable diffusion API.
+ auto_save (bool, optional): Save generated images automatically. Defaults to True.
+
+ Returns:
+ list: The generated images as a result of the API call.
+ """
with requests.Session() as session:
logger.debug(self.sd_t2i_url)
rsp = session.post(self.sd_t2i_url, json=payload, timeout=600)
@@ -98,7 +136,11 @@ class SDEngine:
return results
async def run_t2i(self, payloads: List):
- # Asynchronously run the SD API for multiple prompts
+ """Run the stable diffusion API for multiple prompts asynchronously.
+
+ Args:
+ payloads (list): List of payload, each payload is a dictionary of input parameters for the stable diffusion API.
+ """
session = ClientSession()
for payload_idx, payload in enumerate(payloads):
results = await self.run(url=self.sd_t2i_url, payload=payload, session=session)
@@ -106,7 +148,16 @@ class SDEngine:
await session.close()
async def run(self, url, payload, session):
- # Perform the HTTP POST request to the SD API
+ """Perform the HTTP POST request to the SD API.
+
+ Args:
+ url (str): The API URL.
+ payload (dict): The payload for the request.
+ session (ClientSession): The session for making HTTP requests.
+
+ Returns:
+ list: Images generated by the stable diffusion API.
+ """
async with session.post(url, json=payload, timeout=600) as rsp:
data = await rsp.read()
diff --git a/metagpt/tools/schemas/__init__.py b/metagpt/tools/schemas/__init__.py
deleted file mode 100644
index e50f67d6f..000000000
--- a/metagpt/tools/schemas/__init__.py
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# @Time : 2023/11/16 16:33
-# @Author : lidanyang
-# @File : __init__.py
-# @Desc :
diff --git a/metagpt/tools/schemas/data_preprocess/FillMissingValue.yml b/metagpt/tools/schemas/data_preprocess/FillMissingValue.yml
deleted file mode 100644
index 44c830a1e..000000000
--- a/metagpt/tools/schemas/data_preprocess/FillMissingValue.yml
+++ /dev/null
@@ -1,61 +0,0 @@
-FillMissingValue:
- type: class
- description: "Completing missing values with simple strategies"
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- features:
- type: list
- description: "columns to be processed"
- strategy:
- type: str
- description: "the imputation strategy, notice mean/median can only be used for numeric features"
- default: mean
- enum:
- - mean
- - median
- - most_frequent
- - constant
- fill_value:
- type: int
- description: "fill_value is used to replace all occurrences of missing_values"
- default: null
- required:
- - features
- fit:
- description: "Fit the FillMissingValue model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
diff --git a/metagpt/tools/schemas/data_preprocess/LabelEncode.yml b/metagpt/tools/schemas/data_preprocess/LabelEncode.yml
deleted file mode 100644
index 419ef60a8..000000000
--- a/metagpt/tools/schemas/data_preprocess/LabelEncode.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-LabelEncode:
- type: class
- description: "Apply label encoding to specified categorical columns in-place."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- features:
- type: list
- description: "Categorical columns to be label encoded"
- required:
- - features
- fit:
- description: "Fit the LabelEncode model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
diff --git a/metagpt/tools/schemas/data_preprocess/MaxAbsScale.yml b/metagpt/tools/schemas/data_preprocess/MaxAbsScale.yml
deleted file mode 100644
index 3e17cfdd0..000000000
--- a/metagpt/tools/schemas/data_preprocess/MaxAbsScale.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-MaxAbsScale:
- type: class
- description: "cale each feature by its maximum absolute value"
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- features:
- type: list
- description: "columns to be processed"
- required:
- - features
- fit:
- description: "Fit the MaxAbsScale model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
\ No newline at end of file
diff --git a/metagpt/tools/schemas/data_preprocess/MinMaxScale.yml b/metagpt/tools/schemas/data_preprocess/MinMaxScale.yml
deleted file mode 100644
index 8f050d942..000000000
--- a/metagpt/tools/schemas/data_preprocess/MinMaxScale.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-MinMaxScale:
- type: class
- description: "Transform features by scaling each feature to a range, witch is (0, 1)"
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- features:
- type: list
- description: "columns to be processed"
- required:
- - features
- fit:
- description: "Fit the MinMaxScale model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
diff --git a/metagpt/tools/schemas/data_preprocess/OneHotEncode.yml b/metagpt/tools/schemas/data_preprocess/OneHotEncode.yml
deleted file mode 100644
index f499b2cb8..000000000
--- a/metagpt/tools/schemas/data_preprocess/OneHotEncode.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-OneHotEncode:
- type: class
- description: "Apply one-hot encoding to specified categorical columns, the original columns will be dropped."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- features:
- type: list
- description: "Categorical columns to be one-hot encoded and dropped"
- required:
- - features
- fit:
- description: "Fit the OneHotEncoding model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
diff --git a/metagpt/tools/schemas/data_preprocess/OrdinalEncode.yml b/metagpt/tools/schemas/data_preprocess/OrdinalEncode.yml
deleted file mode 100644
index 79ebaf37c..000000000
--- a/metagpt/tools/schemas/data_preprocess/OrdinalEncode.yml
+++ /dev/null
@@ -1,46 +0,0 @@
-OrdinalEncode:
- type: class
- description: Encode categorical features as ordinal integers.
- methods:
- __init__:
- description: 'Initialize the OrdinalEncode instance with feature names. '
- parameters:
- properties:
- features:
- type: list
- description: List of categorical feature names to be encoded.
- required:
- - features
- fit:
- description: 'Learn the ordinal encodings for the features. '
- parameters:
- properties:
- df:
- type: pd.DataFrame
- description: Dataframe containing the categorical features.
- required:
- - df
- fit_transform:
- description: 'Fit and transform the input DataFrame. '
- parameters:
- properties:
- df:
- type: pd.DataFrame
- description: The input DataFrame.
- required:
- - df
- returns:
- - type: pd.DataFrame
- description: The transformed DataFrame.
- transform:
- description: 'Convert the categorical features to ordinal integers. '
- parameters:
- properties:
- df:
- type: pd.DataFrame
- description: Dataframe containing the categorical features to be encoded.
- required:
- - df
- returns:
- - type: pd.DataFrame
- description: A new dataframe with the encoded features.
diff --git a/metagpt/tools/schemas/data_preprocess/RobustScale.yml b/metagpt/tools/schemas/data_preprocess/RobustScale.yml
deleted file mode 100644
index 6d5dfaf3a..000000000
--- a/metagpt/tools/schemas/data_preprocess/RobustScale.yml
+++ /dev/null
@@ -1,47 +0,0 @@
-RobustScale:
- type: class
- description: Apply the RobustScaler to scale features using statistics that are
- robust to outliers.
- methods:
- __init__:
- description: 'Initialize the RobustScale instance with feature names. '
- parameters:
- properties:
- features:
- type: list
- description: List of feature names to be scaled.
- required:
- - features
- fit:
- description: 'Compute the median and IQR for scaling. '
- parameters:
- properties:
- df:
- type: pd.DataFrame
- description: Dataframe containing the features.
- required:
- - df
- fit_transform:
- description: 'Fit and transform the input DataFrame. '
- parameters:
- properties:
- df:
- type: pd.DataFrame
- description: The input DataFrame.
- required:
- - df
- returns:
- - type: pd.DataFrame
- description: The transformed DataFrame.
- transform:
- description: 'Scale features using the previously computed median and IQR. '
- parameters:
- properties:
- df:
- type: pd.DataFrame
- description: Dataframe containing the features to be scaled.
- required:
- - df
- returns:
- - type: pd.DataFrame
- description: A new dataframe with scaled features.
diff --git a/metagpt/tools/schemas/data_preprocess/StandardScale.yml b/metagpt/tools/schemas/data_preprocess/StandardScale.yml
deleted file mode 100644
index cf6e7d57b..000000000
--- a/metagpt/tools/schemas/data_preprocess/StandardScale.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-StandardScale:
- type: class
- description: "Standardize features by removing the mean and scaling to unit variance"
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- features:
- type: list
- description: "columns to be processed"
- required:
- - features
- fit:
- description: "Fit the StandardScale model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
diff --git a/metagpt/tools/schemas/feature_engineering/CatCount.yml b/metagpt/tools/schemas/feature_engineering/CatCount.yml
deleted file mode 100644
index 049fc7879..000000000
--- a/metagpt/tools/schemas/feature_engineering/CatCount.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-CatCount:
- type: class
- description: "Add value counts of a categorical column as new feature."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- col:
- type: str
- description: "Column for value counts."
- required:
- - col
- fit:
- description: "Fit the CatCount model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
\ No newline at end of file
diff --git a/metagpt/tools/schemas/feature_engineering/CatCross.yml b/metagpt/tools/schemas/feature_engineering/CatCross.yml
deleted file mode 100644
index 5d6303439..000000000
--- a/metagpt/tools/schemas/feature_engineering/CatCross.yml
+++ /dev/null
@@ -1,52 +0,0 @@
-CatCross:
- type: class
- description: "Add pairwise crossed features and convert them to numerical features."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- cols:
- type: list
- description: "Columns to be pairwise crossed, at least 2 columns."
- max_cat_num:
- type: int
- description: "Maximum unique categories per crossed feature."
- default: 100
- required:
- - cols
- fit:
- description: "Fit the CatCross model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
\ No newline at end of file
diff --git a/metagpt/tools/schemas/feature_engineering/GeneralSelection.yml b/metagpt/tools/schemas/feature_engineering/GeneralSelection.yml
deleted file mode 100644
index 2ebf5b397..000000000
--- a/metagpt/tools/schemas/feature_engineering/GeneralSelection.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-GeneralSelection:
- type: class
- description: "Drop all nan feats and feats with only one unique value."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- label_col:
- type: str
- description: "Label column name."
- required:
- - label_col
- fit:
- description: "Fit the GeneralSelection model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
\ No newline at end of file
diff --git a/metagpt/tools/schemas/feature_engineering/GroupStat.yml b/metagpt/tools/schemas/feature_engineering/GroupStat.yml
deleted file mode 100644
index 6e0ba2877..000000000
--- a/metagpt/tools/schemas/feature_engineering/GroupStat.yml
+++ /dev/null
@@ -1,58 +0,0 @@
-GroupStat:
- type: class
- description: "Aggregate specified column in a DataFrame grouped by another column, adding new features named '<agg_col>_<agg_func>_by_<group_col>'."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- group_col:
- type: str
- description: "Column used for grouping."
- agg_col:
- type: str
- description: "Column on which aggregation is performed."
- agg_funcs:
- type: list
- description: >-
- List of aggregation functions to apply, such as ['mean', 'std'].
- Each function must be supported by pandas.
- required:
- - group_col
- - agg_col
- - agg_funcs
- fit:
- description: "Fit the GroupStat model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
\ No newline at end of file
diff --git a/metagpt/tools/schemas/feature_engineering/KFoldTargetMeanEncoder.yml b/metagpt/tools/schemas/feature_engineering/KFoldTargetMeanEncoder.yml
deleted file mode 100644
index 79a673f9f..000000000
--- a/metagpt/tools/schemas/feature_engineering/KFoldTargetMeanEncoder.yml
+++ /dev/null
@@ -1,60 +0,0 @@
-KFoldTargetMeanEncoder:
- type: class
- description: "Adds a new feature to the DataFrame by k-fold mean encoding of a categorical column using the label column."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- col:
- type: str
- description: "Column to be k-fold mean encoded."
- label:
- type: str
- description: "Predicted label column."
- n_splits:
- type: int
- description: "Number of splits for K-fold."
- default: 5
- random_state:
- type: int
- description: "Random seed."
- default: 2021
- required:
- - col
- - label
- fit:
- description: "Fit the KFoldTargetMeanEncoder model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
\ No newline at end of file
diff --git a/metagpt/tools/schemas/feature_engineering/PolynomialExpansion.yml b/metagpt/tools/schemas/feature_engineering/PolynomialExpansion.yml
deleted file mode 100644
index 62e6ad5b3..000000000
--- a/metagpt/tools/schemas/feature_engineering/PolynomialExpansion.yml
+++ /dev/null
@@ -1,548 +0,0 @@
-PolynomialExpansion:
- type: class
- description: "Add polynomial and interaction features from selected numeric columns to input DataFrame."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- cols:
- type: list
- description: "Columns for polynomial expansion."
- label_col:
- type: str
- description: "Label column name."
- degree:
- type: int
- description: "The degree of the polynomial features."
- default: 2
- required:
- - cols
- - label_col
- fit:
- description: "Fit the PolynomialExpansion model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame without duplicated columns."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame without duplicated columns."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
-
-CatCount:
- type: class
- description: "Add value counts of a categorical column as new feature."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- col:
- type: str
- description: "Column for value counts."
- required:
- - col
- fit:
- description: "Fit the CatCount model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
-
-TargetMeanEncoder:
- type: class
- description: "Encodes a categorical column by the mean of the label column, and adds the result as a new feature."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- col:
- type: str
- description: "Column to be mean encoded."
- label:
- type: str
- description: "Predicted label column."
- required:
- - col
- - label
- fit:
- description: "Fit the TargetMeanEncoder model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
-
-KFoldTargetMeanEncoder:
- type: class
- description: "Adds a new feature to the DataFrame by k-fold mean encoding of a categorical column using the label column."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- col:
- type: str
- description: "Column to be k-fold mean encoded."
- label:
- type: str
- description: "Predicted label column."
- n_splits:
- type: int
- description: "Number of splits for K-fold."
- default: 5
- random_state:
- type: int
- description: "Random seed."
- default: 2021
- required:
- - col
- - label
- fit:
- description: "Fit the KFoldTargetMeanEncoder model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
-
-CatCross:
- type: class
- description: "Add pairwise crossed features and convert them to numerical features."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- cols:
- type: list
- description: "Columns to be pairwise crossed, at least 2 columns."
- max_cat_num:
- type: int
- description: "Maximum unique categories per crossed feature."
- default: 100
- required:
- - cols
- fit:
- description: "Fit the CatCross model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
-
-GroupStat:
- type: class
- description: "Aggregate specified column in a DataFrame grouped by another column, adding new features named '<agg_col>_<agg_func>_by_<group_col>'."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- group_col:
- type: str
- description: "Column used for grouping."
- agg_col:
- type: str
- description: "Column on which aggregation is performed."
- agg_funcs:
- type: list
- description: >-
- List of aggregation functions to apply, such as ['mean', 'std'].
- Each function must be supported by pandas.
- required:
- - group_col
- - agg_col
- - agg_funcs
- fit:
- description: "Fit the GroupStat model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
-
-SplitBins:
- type: class
- description: "Inplace binning of continuous data into intervals, returning integer-encoded bin identifiers directly."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- cols:
- type: list
- description: "Columns to be binned inplace."
- strategy:
- type: str
- description: "Strategy used to define the widths of the bins."
- default: quantile
- enum:
- - quantile
- - uniform
- - kmeans
- required:
- - cols
- fit:
- description: "Fit the SplitBins model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
-
-GeneralSelection:
- type: class
- description: "Drop all nan feats and feats with only one unique value."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- label_col:
- type: str
- description: "Label column name."
- required:
- - label_col
- fit:
- description: "Fit the GeneralSelection model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
-
-
-TreeBasedSelection:
- type: class
- description: "Select features based on tree-based model and remove features with low importance."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- label_col:
- type: str
- description: "Label column name."
- task_type:
- type: str
- description: "Task type, 'cls' for classification, 'mcls' for multi-class classification, 'reg' for regression."
- enum:
- - cls
- - mcls
- - reg
- required:
- - label_col
- - task_type
- fit:
- description: "Fit the TreeBasedSelection model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame contain label_col."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame contain label_col."
-
-VarianceBasedSelection:
- type: class
- description: "Select features based on variance and remove features with low variance."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- label_col:
- type: str
- description: "Label column name."
- threshold:
- type: float
- description: "Threshold for variance."
- default: 0.0
- required:
- - label_col
- fit:
- description: "Fit the VarianceBasedSelection model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame contain label_col."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame contain label_col."
\ No newline at end of file
diff --git a/metagpt/tools/schemas/feature_engineering/SplitBins.yml b/metagpt/tools/schemas/feature_engineering/SplitBins.yml
deleted file mode 100644
index 4e0171406..000000000
--- a/metagpt/tools/schemas/feature_engineering/SplitBins.yml
+++ /dev/null
@@ -1,56 +0,0 @@
-SplitBins:
- type: class
- description: "Inplace binning of continuous data into intervals, returning integer-encoded bin identifiers directly."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- cols:
- type: list
- description: "Columns to be binned inplace."
- strategy:
- type: str
- description: "Strategy used to define the widths of the bins."
- default: quantile
- enum:
- - quantile
- - uniform
- - kmeans
- required:
- - cols
- fit:
- description: "Fit the SplitBins model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
\ No newline at end of file
diff --git a/metagpt/tools/schemas/feature_engineering/TargetMeanEncoder.yml b/metagpt/tools/schemas/feature_engineering/TargetMeanEncoder.yml
deleted file mode 100644
index 86416ccbb..000000000
--- a/metagpt/tools/schemas/feature_engineering/TargetMeanEncoder.yml
+++ /dev/null
@@ -1,52 +0,0 @@
-TargetMeanEncoder:
- type: class
- description: "Encodes a categorical column by the mean of the label column, and adds the result as a new feature."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- col:
- type: str
- description: "Column to be mean encoded."
- label:
- type: str
- description: "Predicted label column."
- required:
- - col
- - label
- fit:
- description: "Fit the TargetMeanEncoder model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame."
\ No newline at end of file
diff --git a/metagpt/tools/schemas/feature_engineering/TreeBasedSelection.yml b/metagpt/tools/schemas/feature_engineering/TreeBasedSelection.yml
deleted file mode 100644
index c210effea..000000000
--- a/metagpt/tools/schemas/feature_engineering/TreeBasedSelection.yml
+++ /dev/null
@@ -1,56 +0,0 @@
-TreeBasedSelection:
- type: class
- description: "Select features based on tree-based model and remove features with low importance."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- label_col:
- type: str
- description: "Label column name."
- task_type:
- type: str
- description: "Task type, 'cls' for classification, 'mcls' for multi-class classification, 'reg' for regression."
- enum:
- - cls
- - mcls
- - reg
- required:
- - label_col
- - task_type
- fit:
- description: "Fit the TreeBasedSelection model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame contain label_col."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame contain label_col."
\ No newline at end of file
diff --git a/metagpt/tools/schemas/feature_engineering/VarianceBasedSelection.yml b/metagpt/tools/schemas/feature_engineering/VarianceBasedSelection.yml
deleted file mode 100644
index 6da4c3e7f..000000000
--- a/metagpt/tools/schemas/feature_engineering/VarianceBasedSelection.yml
+++ /dev/null
@@ -1,52 +0,0 @@
-VarianceBasedSelection:
- type: class
- description: "Select features based on variance and remove features with low variance."
- methods:
- __init__:
- description: "Initialize self."
- parameters:
- properties:
- label_col:
- type: str
- description: "Label column name."
- threshold:
- type: float
- description: "Threshold for variance."
- default: 0.0
- required:
- - label_col
- fit:
- description: "Fit the VarianceBasedSelection model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- transform:
- description: "Transform the input DataFrame with the fitted model."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame contain label_col."
- fit_transform:
- description: "Fit and transform the input DataFrame."
- parameters:
- properties:
- df:
- type: DataFrame
- description: "The input DataFrame."
- required:
- - df
- returns:
- df:
- type: DataFrame
- description: "The transformed DataFrame contain label_col."
\ No newline at end of file
diff --git a/metagpt/tools/schemas/image2webpage/GPTvGenerator.yml b/metagpt/tools/schemas/image2webpage/GPTvGenerator.yml
deleted file mode 100644
index 1ba2c2b08..000000000
--- a/metagpt/tools/schemas/image2webpage/GPTvGenerator.yml
+++ /dev/null
@@ -1,36 +0,0 @@
-GPTvGenerator:
- type: class
- description: "Class for generating webpages at once."
- methods:
- __init__:
- description: "Initialize Vision class with default values."
-
- generate_webpages:
- description: "Generate webpages including all code(HTML, CSS and JavaScript) in one go based on the image."
- parameters:
- properties:
- image_path:
- type: str
- description: "The path of the image file"
- required:
- - image_path
- returns:
- type: str
- description: "Generated webpages content."
-
- save_webpages:
- description: "Save webpages including all code(HTML, CSS and JavaScript) at once"
- parameters:
- properties:
- image_path:
- type: str
- description: "The path of the image file"
- webpages:
- type: str
- description: "The generated webpages content"
- required:
- - image_path
- - webpages
- returns:
- type: Path
- description: "The path of the saved webpages"
\ No newline at end of file
diff --git a/metagpt/tools/schemas/stable_diffusion/SDEngine.yml b/metagpt/tools/schemas/stable_diffusion/SDEngine.yml
deleted file mode 100644
index a93742a1d..000000000
--- a/metagpt/tools/schemas/stable_diffusion/SDEngine.yml
+++ /dev/null
@@ -1,58 +0,0 @@
-SDEngine:
- type: class
- description: "Generate image using stable diffusion model"
- methods:
- __init__:
- description: "Initialize the SDEngine instance."
- parameters:
- properties:
- sd_url:
- type: str
- description: "URL of the stable diffusion service."
- simple_run_t2i:
- description: "Run the stable diffusion API for multiple prompts, calling the stable diffusion API to generate images."
- parameters:
- properties:
- payload:
- type: dict
- description: "Dictionary of input parameters for the stable diffusion API."
- auto_save:
- type: bool
- description: "Save generated images automatically."
- required:
- - prompts
- run_t2i:
- type: async function
- description: "Run the stable diffusion API for multiple prompts, calling the stable diffusion API to generate images."
- parameters:
- properties:
- payloads:
- type: list
- description: "List of payload, each payload is a dictionary of input parameters for the stable diffusion API."
- required:
- - payloads
- construct_payload:
- description: "Modify and set the API parameters for image generation."
- parameters:
- properties:
- prompt:
- type: str
- description: "Text input for image generation."
- required:
- - prompt
- returns:
- payload:
- type: dict
- description: "Updated parameters for the stable diffusion API."
- save:
- description: "Save generated images to the output directory."
- parameters:
- properties:
- imgs:
- type: str
- description: "Generated images."
- save_name:
- type: str
- description: "Output image name. Default is empty."
- required:
- - imgs
diff --git a/metagpt/tools/schemas/web_scraping/scrape_web_playwright.yml b/metagpt/tools/schemas/web_scraping/scrape_web_playwright.yml
deleted file mode 100644
index a6ff7d6c7..000000000
--- a/metagpt/tools/schemas/web_scraping/scrape_web_playwright.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-scrape_web_playwright:
- type: async funciton
- description: "Scrape and save the HTML structure and inner text content of a web page using Playwright."
- parameters:
- properties:
- url:
- type: str
- description: "web url"
- \*url:
- type: Non-Keyword Arguments
- description: "other web urls, you can assagin sub url link to it."
- required:
- - url
- returns:
- inner_text:
- type: str
- description: The inner text content of the web page.
- html:
- type: str
- description: The html structure of the web page.
-