偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

阿里重磅開源AgentScope,多智能體應(yīng)用開發(fā)利器

發(fā)布于 2025-9-26 06:54
瀏覽
0收藏

阿里巴巴悄然發(fā)布了 AgentScope。這是一個(gè)用于構(gòu)建多代理 AI 應(yīng)用的開源 Python 框架。

老實(shí)說,如果你一直在玩 AI agents,這玩意兒挺酷的。

我花了點(diǎn)時(shí)間挖了挖它,我的收獲是:感覺終于有人試著做了一個(gè)不跟你對(duì)著干的 agents 框架。

大多數(shù)框架藏得太深,或者把你鎖死在一種工作方式里。

AgentScope 的賣點(diǎn)正好相反;一切都保持可見,你保持控制。

沒有黑箱魔法。

阿里重磅開源AgentScope,多智能體應(yīng)用開發(fā)利器-AI.x社區(qū)

為什么它吸引了我的注意

AgentScope 背后的那些人似乎癡迷于一個(gè)想法:透明度。每件東西,prompts、API calls、memory、工作流,你都能看到并調(diào)整。這很少見。

還有幾點(diǎn)我喜歡的東西:

你可以實(shí)時(shí)中斷 agents,然后不破壞 memory 就撿起來繼續(xù)。 它是 model-agnostic 的,所以你不會(huì)被困在一個(gè) LLM 上。 所有部分(memory、tools、prompts、工作流)像 LEGO 積木一樣 snap together。 它其實(shí)是為多代理對(duì)話設(shè)計(jì)的,不是事后想的。 感覺像一個(gè) dev toolkit,想讓你別被它擋路。

阿里重磅開源AgentScope,多智能體應(yīng)用開發(fā)利器-AI.x社區(qū)


圖片來自 — AgentScope

讓它運(yùn)行起來

設(shè)置有點(diǎn)無聊但容易。你需要 Python 3.10 或以上。

如果你想走快捷路線:

pip install agentscope

或者如果你喜歡活在邊緣(source build):

git clone -b main https://github.com/agentscope-ai/agentscope.git
cd agentscope
pip install -e .

就這么著。

阿里重磅開源AgentScope,多智能體應(yīng)用開發(fā)利器-AI.x社區(qū)


第一個(gè)“Hello World”用一個(gè)叫 Friday 的 agent。

這是經(jīng)典的入門例子,啟動(dòng)一個(gè)叫 Friday 的 agent,它能跟你聊天,記住上下文,甚至如果你允許的話運(yùn)行 Python 或 shell 命令。

from agentscope.agent import ReActAgent, UserAgent
from agentscope.model import DashScopeChatModel
from agentscope.formatter import DashScopeChatFormatter
from agentscope.memory import InMemoryMemory
from agentscope.tool import Toolkit, execute_python_code, execute_shell_command
import os, asyncio


async def main():
    toolkit = Toolkit()
    toolkit.register_tool_function(execute_python_code)
    toolkit.register_tool_function(execute_shell_command)

    agent = ReActAgent(
        name="Friday",
        sys_prompt="You're a helpful assistant named Friday.",
        model=DashScopeChatModel(
            model_name="qwen-max",
            api_key=os.environ["DASHSCOPE_API_KEY"],
            stream=True,
        ),
        memory=InMemoryMemory(),
        formatter=DashScopeChatFormatter(),
        toolkit=toolkit,
    )

    user = UserAgent(name="user")

    msg = None
    while True:
        msg = await agent(msg)
        msg = await user(msg)
        if msg.get_text_content() == "exit":
            break

asyncio.run(main())

運(yùn)行它,跟 Friday 聊天,輸入 exit 就完事。超級(jí)直截了當(dāng)。

阿里重磅開源AgentScope,多智能體應(yīng)用開發(fā)利器-AI.x社區(qū)


實(shí)時(shí) steering

一個(gè)突出的功能是他們叫 real-time steering 的東西。

假設(shè)你的 agent 正在進(jìn)行推理鏈的中途,你突然意識(shí)到想改變方向。

通常,那游戲就結(jié)束了。

在這里,你可以隨時(shí)中斷它,保留它的 memory,然后不丟失上下文就繼續(xù)。

感覺更像和一個(gè)真正的助手聊天,而不是運(yùn)行一個(gè)腳本。

阿里重磅開源AgentScope,多智能體應(yīng)用開發(fā)利器-AI.x社區(qū)

MCP Control

AgentScope 也和 MCP (Model Context Protocol) 玩得很好??岬牟糠??你可以抓一個(gè) MCP endpoint,把它當(dāng)本地函數(shù)用。

from agentscope.mcp import HttpStatelessClient
from agentscope.tool import Toolkit
import os

async def fine_grained_mcp_control():
    # Initialize the MCP client
    client = HttpStatelessClient(
        name="gaode_mcp",
        transport="streamable_http",
        url=f"https://mcp.amap.com/mcp?key={os.environ['GAODE_API_KEY']}",
    )

    # Obtain the MCP tool as a **local callable function**, and use it anywhere
    func = await client.get_callable_function(func_name="maps_geo")

    # Option 1: Call directly
    await func(address="Tiananmen Square", city="Beijing")

    # Option 2: Pass to agent as a tool
    toolkit = Toolkit()
    toolkit.register_tool_function(func)
    # ...

    # Option 3: Wrap into a more complex tool
    # ...

這意味著你每次想連接 MCP 服務(wù)時(shí),不用每次都建 glue code。

阿里重磅開源AgentScope,多智能體應(yīng)用開發(fā)利器-AI.x社區(qū)


多代理樂趣

真正的魔法發(fā)生在你讓 agents 互相聊天時(shí)。AgentScope 有這個(gè)叫 MsgHub 的東西,基本上是個(gè)多代理的消息路由器。

例子:

from agentscope.pipeline import MsgHub, sequential_pipeline
from agentscope.message import Msg
import asyncio

async def multi_agent_conversation():
    # Create agents
    agent1 = ...
    agent2 = ...
    agent3 = ...
    agent4 = ...

    # Create a message hub to manage multi-agent conversation
    async with MsgHub(
        participants=[agent1, agent2, agent3],
        announcement=Msg("Host", "Introduce yourselves.", "assistant")
    ) as hub:
        # Speak in a sequential manner
        await sequential_pipeline([agent1, agent2, agent3])
        # Dynamic manage the participants
        hub.add(agent4)
        hub.delete(agent3)
        await hub.broadcast(Msg("Host", "Goodbye!", "assistant"))

asyncio.run(multi_agent_conversation())

換句話說,你可以啟動(dòng)小“agent societies”,它們互相拋想法。適合 brainstorm 系統(tǒng)或任務(wù)編排。

調(diào)試

Tracing 是內(nèi)置的。他們在 hood 下用 OpenTelemetry,你可以 plug into 像 Langfuse 或 Arize-Phoenix 這樣的平臺(tái)。

如果你想視覺化看發(fā)生了啥:

npm install -g @agentscope/studio

as_studio

那會(huì)打開 AgentScope Studio,你可以 trace 和 visualise 你的 agent flows。讓調(diào)試沒那么痛苦。

Github地址:???https://github.com/agentscope-ai/agentscope??

本文轉(zhuǎn)載自????PyTorch研習(xí)社????,作者:AI研究生

已于2025-9-26 06:58:00修改
收藏
回復(fù)
舉報(bào)
回復(fù)
相關(guān)推薦