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 的新类,指定 name、description 和用于操作逻辑的 _run 方法。
使用 tool 装饰器
对于更简单的方法,请直接使用所需的属性和功能逻辑创建 Tool 对象。
from crewai_tools import tool
@tool("我的工具名称")
def my_tool(question: str) -> str:
"""对该工具用途的清晰描述,您的代理将需要此信息才能使用它。"""
# 函数逻辑在此处
tool 装饰器简化了流程,以最小的开销将函数转换为工具。
贡献指南
我们热烈欢迎您为丰富此工具集做出贡献。要做出贡献:
- **Fork 仓库:**首先将仓库 fork 到您的 GitHub 帐户。
- **功能分支:**在您的 fork 中为功能或改进创建一个新分支。
- **实现您的功能:**将您的贡献添加到新分支中。
- **拉取请求:**从您的功能分支向主仓库提交拉取请求。
我们非常感谢您的贡献,这将有助于增强此项目。
开发设置
安装依赖项:
poetry install
激活虚拟环境:
poetry shell
设置预提交钩子:
pre-commit install
运行测试:
poetry run pytest
静态类型检查:
poetry run pyright
打包:
poetry build
本地安装:
pip install dist/*.tar.gz
感谢您有兴趣通过高级工具增强 AI 代理的功能。您的贡献将产生重大影响。
Metadata
Release files for aipmai-tools 0.4.26
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aipmai_tools-0.4.26.tar.gz | 45.4 kB | Without provenance | Details for aipmai_tools-0.4.26.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aipmai_tools-0.4.26-py3-none-any.whl | Python 3 | none | any | Details for aipmai_tools-0.4.26-py3-none-any.whl |
Total release size: 136.7 kB
Release files / aipmai_tools-0.4.26.tar.gz
| Download URL | aipmai_tools-0.4.26.tar.gz |
|---|---|
| Size | 45.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a542639f83625402e404a7a5709db6b59ef807a7e3fc558525bce0afb00e9d26
|
|
BLAKE2b-256 checksum How to use checksums |
e4bfc565a2b41f392b8e136b4144281136e37c5ef077b4e150fcc24b7345b611
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / aipmai_tools-0.4.26-py3-none-any.whl
| Download URL | aipmai_tools-0.4.26-py3-none-any.whl |
|---|---|
| Size | 91.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
732a51275662a01d341152877d128628fe0e9149c2c67f71d8aa6936ca8425bf
|
|
BLAKE2b-256 checksum How to use checksums |
be54ff835e1bc51ef84b3d1054fbe2e0bde99e3949225f582b5b9801a7555144
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Security for aipmai-tools 0.4.26
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.