Composio:AI代理的生产级工具集

Composio:AI代理的生产级工具集

composio Composio equips agents with well-crafted tools empowering them to tackle complex tasks composio 项目地址: https://gitcode.com/gh_mirrors/co/composio

在人工智能技术迅猛发展的今天,AI代理的应用场景日益丰富,而一个强大的工具集则是实现高效代理的关键。Composio 正是这样一款为 AI 代理提供生产就绪工具集的开源项目,它集成了250多种工具,覆盖了从操作系统操作到搜索功能的广泛类别。

项目介绍

Composio 是一个专门为 AI 代理设计的工具集,旨在简化 AI 代理的开发和部署流程。它不仅支持GitHub、Notion、Linear、Gmail、Slack、Hubspot、Salesforce等众多软件工具,还包括操作系统级别的文件工具、shell工具、代码分析工具,以及通过 Google、Perplexity、Tavily 和 Exa 实现的搜索功能。

项目技术分析

Composio 提供了全面的框架支持,包括 OpenAI、Groq、Claude、LlamaIndex、Langchain、CrewAI、Autogen、Gemini 等主流框架,这意味着开发者可以在多种环境中使用 Composio。此外,Composio 还支持多种身份验证协议,如 OAuth、API 密钥、Basic JWT,确保了在不同应用场景中的安全性和灵活性。

项目及技术应用场景

Composio 的设计优化显著提高了工具调用的准确率,最高可达40%。这使得它在处理复杂的任务时更加高效和可靠。无论是后端集成还是自定义工具,Composio 的可插拔架构都能轻松应对,满足不同应用场景的需求。例如,在自动化测试、数据分析和智能客服等领域,Composio 都能发挥重要作用。

项目特点

  1. 丰富的工具集:支持250多种工具,涵盖多种类别,满足不同场景需求。
  2. 全面的框架支持:与主流 AI 框架兼容,提供更大的灵活性和扩展性。
  3. 安全的身份验证:支持多种协议,确保数据安全和合规性。
  4. 优化设计:工具调用准确率提高高达40%,提升代理效率。
  5. 可插拔架构:支持自定义工具和后端集成,满足个性化需求。

下面,我们将通过一些示例来展示如何使用 Composio。

Python 示例

from openai import OpenAI
from composio_openai import ComposioToolSet, App, Action

openai_client = OpenAI(api_key="YOUR_OPENAI_API_KEY")

# 初始化 Composio 工具集
composio_tool_set = ComposioToolSet()

# 获取预先配置的 GitHub 工具
actions = composio_tool_set.get_actions(
    actions=[Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER]
)

my_task = "Star a repo composiodev/composio on GitHub"

# 设置 openai 助手
assistant_instruction = "You are a super intelligent personal assistant"

assistant = openai_client.beta.assistants.create(
    name="Personal Assistant",
    instructions=assistant_instruction,
    model="gpt-4-turbo",
    tools=actions,
)

# 创建线程
thread = openai_client.beta.threads.create()

message = openai_client.beta.threads.messages.create(
    thread_id=thread.id, role="user", content=my_task
)

# 使用集成执行代理
run = openai_client.beta.threads.runs.create(
    thread_id=thread.id, assistant_id=assistant.id
)

# 执行函数调用
response_after_tool_calls = composio_tool_set.wait_and_handle_assistant_tool_calls(
    client=openai_client,
    run=run,
    thread=thread,
)

print(response_after_tool_calls)

JavaScript 示例

import { OpenAIToolSet } from "composio-core";
import OpenAI from "openai";

const toolset = new OpenAIToolSet({ apiKey: process.env.COMPOSIO_API_KEY });
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

const tools = await toolset.getTools({ actions: ["GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER"] });

async function createGithubAssistant(openai, tools) {
    return await openai.beta.assistants.create({
        name: "Github Assistant",
        instructions: "You're a GitHub Assistant, you can do operations on GitHub",
        tools: tools,
        model: "gpt-4o"
    });
}

async function executeAssistantTask(openai, toolset, assistant, task) {
    const thread = await openai.beta.threads.create();
    const run = await openai.beta.threads.runs.create(thread.id, {
        assistant_id: assistant.id,
        instructions: task,
        tools: tools,
        model: "gpt-4o",
        stream: false
    });
    const call = await toolset.waitAndHandleAssistantToolCalls(openai, run, thread);
    console.log(call);
}

(async () => {
    const githubAssistant = await createGithubAssistant(openai, tools);
    await executeAssistantTask(
        openai,
        toolset,
        githubAssistant,
        "Star the repository 'composiohq/composio'"
    );
})();

通过这些示例,我们可以看到 Composio 如何简化 AI 代理的开发过程。无论是 Python 还是 JavaScript,Composio 都提供了直观的 API,使得创建和执行 AI 代理变得更加容易。如果你对 Composio 感兴趣,不妨尝试集成到你的项目中,体验它的强大功能和灵活应用。

composio Composio equips agents with well-crafted tools empowering them to tackle complex tasks composio 项目地址: https://gitcode.com/gh_mirrors/co/composio

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

幸愉旎Jasper

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值