Skip to content

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

Merge branch 'code_intepreter' of https://gitlab.deepwisdomai.com/agents/data_agents_opt into code_intepreter

stellahsr75134d205d5d
diff --cc examples/sd_tool_usage.py
index 82ee6a709,000000000..e470ff0b6
mode 100644,000000..100644
--- a/examples/sd_tool_usage.py
+++ b/examples/sd_tool_usage.py
@@@ -1,19 -1,0 +1,21 @@@
+# -*- coding: utf-8 -*-
+# @Date : 1/11/2024 7:06 PM
+# @Author : stellahong ([email protected])
+# @Desc :
+import asyncio
+
+from metagpt.roles.code_interpreter import CodeInterpreter
+
+
+async def main(requirement: str = ""):
+ code_interpreter = CodeInterpreter(use_tools=True, goal=requirement)
+ await code_interpreter.run(requirement)
+
+
+if __name__ == "__main__":
- sd_url = 'http://106.75.10.65:19094'
- requirement = f"I want to generate an image of a beautiful girl using the stable diffusion text2image tool, sd_url={sd_url}"
-
++ sd_url = "http://106.75.10.65:19094"
++ requirement = (
++ f"I want to generate an image of a beautiful girl using the stable diffusion text2image tool, sd_url={sd_url}"
++ )
++
+ asyncio.run(main(requirement))
diff --cc metagpt/tools/__init__.py
index aab8c990c,543a2b8bb..718ec4a34
--- a/metagpt/tools/__init__.py
+++ b/metagpt/tools/__init__.py
@@@ -6,9 -6,19 +6,18 @@@
@File : __init__.py
"""
--
from enum import Enum
+ from pydantic import BaseModel
+
+ from metagpt.const import TOOL_SCHEMA_PATH
+ from metagpt.prompts.tool_type import (
+ DATA_PREPROCESS_PROMPT,
+ FEATURE_ENGINEERING_PROMPT,
+ MODEL_TRAIN_PROMPT,
+ MODEL_EVALUATE_PROMPT,
+ )
+
class SearchEngineType(Enum):
SERPAPI_GOOGLE = "serpapi"
@@@ -27,3 -37,44 +36,50 @@@ class WebBrowserEngineType(Enum)
def __missing__(cls, key):
"""Default type conversion"""
return cls.CUSTOM
+
+
+ class ToolType(BaseModel):
+ name: str
+ module: str = ""
+ desc: str
+ usage_prompt: str = ""
+
+
+ TOOL_TYPE_MAPPINGS = {
+ "data_preprocess": ToolType(
+ name="data_preprocess",
+ module=str(TOOL_SCHEMA_PATH / "data_preprocess"),
+ desc="Only for changing value inplace.",
+ usage_prompt=DATA_PREPROCESS_PROMPT,
+ ),
+ "feature_engineering": ToolType(
+ name="feature_engineering",
+ module=str(TOOL_SCHEMA_PATH / "feature_engineering"),
+ desc="Only for creating new columns for input data.",
+ usage_prompt=FEATURE_ENGINEERING_PROMPT,
+ ),
+ "model_train": ToolType(
+ name="model_train",
+ module="",
+ desc="Only for training model.",
+ usage_prompt=MODEL_TRAIN_PROMPT,
+ ),
+ "model_evaluate": ToolType(
+ name="model_evaluate",
+ module="",
+ desc="Only for evaluating model.",
+ usage_prompt=MODEL_EVALUATE_PROMPT,
+ ),
++ "stable_diffusion": ToolType(
++ name="stable_diffusion",
++ module="metagpt.tools.sd_engine",
++ desc="Related to text2image, image2image using stable diffusion model.",
++ usage_prompt="",
++ ),
+ "other": ToolType(
+ name="other",
+ module="",
+ desc="Any tasks that do not fit into the previous categories",
+ usage_prompt="",
+ ),
+ }