Skip to main content

Set of tools for the crewAI framework (Chinese Version)

Project description

crewAI 的 Logo,两个人在一艘船上划船

crewAI 工具

本文档全面介绍了如何为 crewAI 代理设置复杂的工具,方便创建定制工具以增强您的 AI 解决方案。

在 CrewAI 代理领域,工具对于增强功能至关重要。本指南概述了为您的代理配备一系列现成工具的步骤,以及创建您自己的工具的方法。

主页 | aipmAI - crewAI 中文解决方案 | 与文档聊天 | 示例 | Discord

目录

创建您的工具

工具始终应返回字符串,因为它们旨在供代理用于生成响应。

创建 crewAI 代理工具的方法有三种:

继承 BaseTool

from crewai_tools import BaseTool

class MyCustomTool(BaseTool):
    name: str = "我的工具名称"
    description: str = "对该工具用途的清晰描述,您的代理将需要此信息才能使用它。"

    def _run(self, argument: str) -> str:
        # 实现代码在此处
        pass

定义一个继承自 BaseTool 的新类,指定 namedescription 和用于操作逻辑的 _run 方法。

使用 tool 装饰器

对于更简单的方法,请直接使用所需的属性和功能逻辑创建 Tool 对象。

from crewai_tools import tool
@tool("我的工具名称")
def my_tool(question: str) -> str:
    """对该工具用途的清晰描述,您的代理将需要此信息才能使用它。"""
    # 函数逻辑在此处

tool 装饰器简化了流程,以最小的开销将函数转换为工具。

贡献指南

我们热烈欢迎您为丰富此工具集做出贡献。要做出贡献:

  1. **Fork 仓库:**首先将仓库 fork 到您的 GitHub 帐户。
  2. **功能分支:**在您的 fork 中为功能或改进创建一个新分支。
  3. **实现您的功能:**将您的贡献添加到新分支中。
  4. **拉取请求:**从您的功能分支向主仓库提交拉取请求。

我们非常感谢您的贡献,这将有助于增强此项目。

开发设置

安装依赖项:

poetry install

激活虚拟环境:

poetry shell

设置预提交钩子:

pre-commit install

运行测试:

poetry run pytest

静态类型检查:

poetry run pyright

打包:

poetry build

本地安装:

pip install dist/*.tar.gz

感谢您有兴趣通过高级工具增强 AI 代理的功能。您的贡献将产生重大影响。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aipmai_tools-0.4.26.tar.gz (45.4 kB view hashes)

Uploaded Source

Built Distribution

aipmai_tools-0.4.26-py3-none-any.whl (91.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page