Composio - AI 代理工具集


一、关于 Composio

Composo 是 AI代理的生产就绪工具集,为代理提供精心设计的工具,使他们能够处理复杂的任务


为什么是Composo?🤔

我们相信基于AI的代理/工作流是未来。Composo是将AI代理集成到最佳代理工具并使用它们来完成任务的最佳工具集。


主要特点 🔥

  • 100多种工具:支持一系列不同的类别
    • 软件:在GitHub、Notion、Linear、Gmail、Slack、Hubspot、赛福时等90个平台上做任何事情。
    • 操作系统:单击任意位置,键入任何内容,复制到剪切板等。
    • 浏览器:智能搜索、截屏、MultiOn、下载、上传等。
    • 搜索:谷歌搜索、困惑搜索、Tavily、Exa等。
    • SWE:Ngrok、数据库、Redis、Vercel、Git等。
    • RAG:用于任何类型数据的代理RAG!
  • 框架:在一行代码中使用带有代理框架的工具,如OpenAI、Claude、LlamaIndex、Langchain、CrewAI、Autogen、Double、Julep、Lyzr等。
  • 托管授权:支持六种不同的身份验证协议。访问代币、刷新代币、OAuth、API密钥、JWT等等,因此您可以专注于构建代理。
  • 精度:由于更好的工具设计,在您的工具调用中获得高达40%的代理精度。
  • 可嵌入:应用程序后端的Whitelabel为所有用户和代理管理身份验证和集成,并保持一致的体验。
  • 可插拔:旨在非常轻松地使用其他工具、框架和授权协议进行扩展。

例子💡


二、Python入门🚀


1、安装

要开始使用,请在终端中键入以下命令。

pip install composio-core

如果您想安装’composo’包及其openai插件:

pip install composio-openai

2、马上测试 Composio

让我们使用Composo创建一个可以启动Github Repo的AI代理。

composio add github # Connect your Github - Run this in terminal

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

openai_client = OpenAI(
    api_key="{{OPENAIKEY}}"
)

# Initialise the Composio Tool Set

composio_tool_set = ComposioToolSet()

# Get GitHub tools that are pre-configured
actions = composio_tool_set.get_actions(
    actions=[Action.GITHUB_ACTIVITY_STAR_REPO_FOR_AUTHENTICATED_USER]
)

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

# Setup openai assistant
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,
)

# create a thread
thread = openai_client.beta.threads.create()

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

# Execute Agent with integrations
run = openai_client.beta.threads.runs.create(
    thread_id=thread.id,
    assistant_id=assistant.id
)

# Execute Function calls
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入门

要开始使用Javascript中的Composo SDK,请执行以下步骤:


1、安装Composo SDK:

npm install composio-core

2、设置OpenAI和 Composio 工具集:

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

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

async function setupUserConnectionIfNotExists(entityId) {
    const entity = await toolset.client.getEntity(entityId);
    const connection = await entity.getConnection('github');

    if (!connection) {
        // If this entity/user hasn't already connected the account
        const connection = await entity.initiateConnection(appName);
        console.log("Log in via: ", connection.redirectUrl);
        return connection.waitUntilActive(60);
    }

    return connection;
}

async function executeAgent(entityName) {
    const entity = await toolset.client.getEntity(entityName)
    await setupUserConnectionIfNotExists(entity.id);

    const tools = await toolset.get_actions({ actions: ["github_issues_create"] }, entity.id);
    const instruction = "Make an issue with sample title in the repo - himanshu-dixit/custom-repo-breaking"

    const client = new OpenAI({ apiKey: process.env.OPEN_AI_API_KEY })
    const response = await client.chat.completions.create({
        model: "gpt-4-turbo",
        messages: [{
            role: "user",
            content: instruction,
        }],
        tools: tools,
        tool_choice: "auto",
    })

    console.log(response.choices[0].message.tool_calls);
    await toolset.handle_tool_call(response, entity.id);
}

executeAgent("your-entity-name");

3.运行您的脚本:

node your_script.js

这将设置Composo SDK并执行一个代理,该代理使用提供的指令创建GitHub问题。

更多详情可见Composo SDK文档


2024-07-25(四)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

编程乐园

请我喝杯伯爵奶茶~!

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

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

打赏作者

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

抵扣说明:

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

余额充值