Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 22 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@
>
> **About Framework-Agnostic**: Currently, AgentScope Runtime supports the **AgentScope** framework. We plan to extend compatibility to more agent development frameworks in the future. This table shows the current version’s adapter support for different frameworks. The level of support for each functionality varies across frameworks:
>
> | Framework/Feature | Message/Event | Tool | Service |
> | ------------------------------------------------------------ | ------------- | ---- | ------- |
> | [AgentScope](https://runtime.agentscope.io/en/quickstart.html) | ✅ | ✅ | ✅ |
> | [LangGraph](https://runtime.agentscope.io/en/langgraph_guidelines.html) | ✅ | 🚧 | 🚧 |
> | [Microsoft Agent Framework](https://runtime.agentscope.io/en/ms_agent_framework_guidelines.html) | ✅ | ✅ | 🚧 |
> | [Agno](https://runtime.agentscope.io/en/agno_guidelines.html) | ✅ | ✅ | 🚧 |
> | AutoGen | 🚧 | ✅ | 🚧 |
> | Framework/Feature | Message/Event | Tool |
> | ------------------------------------------------------------ | ------------- | ---- |
> | [AgentScope](https://runtime.agentscope.io/en/quickstart.html) | ✅ | ✅ |
> | [LangGraph](https://runtime.agentscope.io/en/langgraph_guidelines.html) | ✅ | 🚧 |
> | [Microsoft Agent Framework](https://runtime.agentscope.io/en/ms_agent_framework_guidelines.html) | ✅ | ✅ |
> | [Agno](https://runtime.agentscope.io/en/agno_guidelines.html) | ✅ | ✅ |
> | AutoGen | 🚧 | ✅ |

---

Expand Down Expand Up @@ -155,14 +155,11 @@ from agentscope.formatter import DashScopeChatFormatter
from agentscope.tool import Toolkit, execute_python_code
from agentscope.pipeline import stream_printing_messages
from agentscope.memory import InMemoryMemory
from agentscope.session import RedisSession

from agentscope_runtime.engine import AgentApp
from agentscope_runtime.engine.schemas.agent_schemas import AgentRequest

from agentscope_runtime.engine.services.agent_state import (
InMemoryStateService,
)

agent_app = AgentApp(
app_name="Friday",
app_description="A helpful assistant",
Expand All @@ -171,14 +168,13 @@ agent_app = AgentApp(

@agent_app.init
async def init_func(self):
self.state_service = InMemoryStateService()

await self.state_service.start()

import fakeredis

@agent_app.shutdown
async def shutdown_func(self):
await self.state_service.stop()
fake_redis = fakeredis.aioredis.FakeRedis(decode_responses=True)
# NOTE: This FakeRedis instance is for development/testing only.
# In production, replace it with your own Redis client/connection
# (e.g., aioredis.Redis)
self.session = RedisSession(connection_pool=fake_redis.connection_pool)


@agent_app.query(framework="agentscope")
Expand All @@ -191,11 +187,6 @@ async def query_func(
session_id = request.session_id
user_id = request.user_id

state = await self.state_service.export_state(
session_id=session_id,
user_id=user_id,
)

toolkit = Toolkit()
toolkit.register_tool_function(execute_python_code)

Expand All @@ -213,21 +204,22 @@ async def query_func(
)
agent.set_console_output_enabled(enabled=False)

if state:
agent.load_state_dict(state)
await self.session.load_session_state(
session_id=session_id,
user_id=user_id,
agent=agent,
)

async for msg, last in stream_printing_messages(
agents=[agent],
coroutine_task=agent(msgs),
):
yield msg, last

state = agent.state_dict()

await self.state_service.save_state(
user_id=user_id,
await self.session.save_session_state(
session_id=session_id,
state=state,
user_id=user_id,
agent=agent,
)


Expand Down
52 changes: 22 additions & 30 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@
>
> **关于框架无关**:当前,AgentScope Runtime 支持 **AgentScope** 框架。未来我们计划扩展支持更多智能体开发框架。该表格展示了目前版本针对不同框架的适配器(adapter)支持情况,不同框架在各功能上的支持程度有所差异:
>
> | 框架 / 功能项 | 消息 / 事件 | 工具 | 服务 |
> | ------------------------------------------------------------ | ------------- | ---- | ------- |
> | [AgentScope](https://runtime.agentscope.io/zh/quickstart.html) | ✅ | ✅ | ✅ |
> | [LangGraph](https://runtime.agentscope.io/zh/langgraph_guidelines.html) | ✅ | 🚧 | 🚧 |
> | [Microsoft Agent Framework](https://runtime.agentscope.io/zh/ms_agent_framework_guidelines.html) | ✅ | ✅ | 🚧 |
> | [Agno](https://runtime.agentscope.io/zh/agno_guidelines.html) | ✅ | ✅ | 🚧 |
> | AutoGen | 🚧 | ✅ | 🚧 |
> | 框架 / 功能项 | 消息 / 事件 | 工具 |
> | ------------------------------------------------------------ | ------------- | ---- |
> | [AgentScope](https://runtime.agentscope.io/zh/quickstart.html) | ✅ | ✅ |
> | [LangGraph](https://runtime.agentscope.io/zh/langgraph_guidelines.html) | ✅ | 🚧 |
> | [Microsoft Agent Framework](https://runtime.agentscope.io/zh/ms_agent_framework_guidelines.html) | ✅ | ✅ |
> | [Agno](https://runtime.agentscope.io/zh/agno_guidelines.html) | ✅ | ✅ |
> | AutoGen | 🚧 | ✅ |

---

Expand Down Expand Up @@ -157,14 +157,11 @@ from agentscope.formatter import DashScopeChatFormatter
from agentscope.tool import Toolkit, execute_python_code
from agentscope.pipeline import stream_printing_messages
from agentscope.memory import InMemoryMemory
from agentscope.session import RedisSession

from agentscope_runtime.engine import AgentApp
from agentscope_runtime.engine.schemas.agent_schemas import AgentRequest

from agentscope_runtime.engine.services.agent_state import (
InMemoryStateService,
)

agent_app = AgentApp(
app_name="Friday",
app_description="A helpful assistant",
Expand All @@ -173,14 +170,13 @@ agent_app = AgentApp(

@agent_app.init
async def init_func(self):
self.state_service = InMemoryStateService()

await self.state_service.start()

import fakeredis

@agent_app.shutdown
async def shutdown_func(self):
await self.state_service.stop()
fake_redis = fakeredis.aioredis.FakeRedis(decode_responses=True)
# 注意:这个 FakeRedis 实例仅用于开发/测试。
# 在生产环境中,请替换为你自己的 Redis 客户端/连接
#(例如 aioredis.Redis)。
self.session = RedisSession(connection_pool=fake_redis.connection_pool)


@agent_app.query(framework="agentscope")
Expand All @@ -193,11 +189,6 @@ async def query_func(
session_id = request.session_id
user_id = request.user_id

state = await self.state_service.export_state(
session_id=session_id,
user_id=user_id,
)

toolkit = Toolkit()
toolkit.register_tool_function(execute_python_code)

Expand All @@ -215,21 +206,22 @@ async def query_func(
)
agent.set_console_output_enabled(enabled=False)

if state:
agent.load_state_dict(state)
await self.session.load_session_state(
session_id=session_id,
user_id=user_id,
agent=agent,
)

async for msg, last in stream_printing_messages(
agents=[agent],
coroutine_task=agent(msgs),
):
yield msg, last

state = agent.state_dict()

await self.state_service.save_state(
user_id=user_id,
await self.session.save_session_state(
session_id=session_id,
state=state,
user_id=user_id,
agent=agent,
)


Expand Down
10 changes: 2 additions & 8 deletions cookbook/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ parts:
sections:
- file: en/sandbox/sandbox.md
sections:
- file: en/sandbox/sandbox_service.md
- file: en/sandbox/advanced.md
- file: en/sandbox/training_sandbox.md
- file: en/sandbox/troubleshooting.md
Expand All @@ -21,10 +22,6 @@ parts:
- file: en/tools/modelstudio_generations.md
- file: en/tools/alipay.md
- file: en/tools/realtime_clients.md
- file: en/service/service.md
sections:
- file: en/service/sandbox.md
- file: en/service/state.md
- file: en/deployment.md
sections:
- file: en/agent_app.md
Expand Down Expand Up @@ -73,6 +70,7 @@ parts:
sections:
- file: zh/sandbox/sandbox.md
sections:
- file: zh/sandbox/sandbox_service.md
- file: zh/sandbox/advanced.md
- file: zh/sandbox/training_sandbox.md
- file: zh/sandbox/troubleshooting.md
Expand All @@ -83,10 +81,6 @@ parts:
- file: zh/tools/modelstudio_generations.md
- file: zh/tools/alipay.md
- file: zh/tools/realtime_clients.md
- file: zh/service/service.md
sections:
- file: zh/service/sandbox.md
- file: zh/service/state.md
- file: zh/deployment.md
sections:
- file: zh/agent_app.md
Expand Down
36 changes: 15 additions & 21 deletions cookbook/en/advanced_deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,10 @@ from agentscope.model import DashScopeChatModel
from agentscope.pipeline import stream_printing_messages
from agentscope.tool import Toolkit, execute_python_code
from agentscope.memory import InMemoryMemory
from agentscope.session import RedisSession

from agentscope_runtime.engine.app import AgentApp
from agentscope_runtime.engine.schemas.agent_schemas import AgentRequest
from agentscope_runtime.engine.services.agent_state import (
InMemoryStateService,
)

app = AgentApp(
app_name="Friday",
Expand All @@ -125,13 +123,13 @@ app = AgentApp(

@app.init
async def init_func(self):
self.state_service = InMemoryStateService()
await self.state_service.start()

import fakeredis

@app.shutdown
async def shutdown_func(self):
await self.state_service.stop()
fake_redis = fakeredis.aioredis.FakeRedis(decode_responses=True)
# NOTE: This FakeRedis instance is for development/testing only.
# In production, replace it with your own Redis client/connection
# (e.g., aioredis.Redis)
self.session = RedisSession(connection_pool=fake_redis.connection_pool)


@app.query(framework="agentscope")
Expand All @@ -145,11 +143,6 @@ async def query_func(
session_id = request.session_id
user_id = request.user_id

state = await self.state_service.export_state(
session_id=session_id,
user_id=user_id,
)

toolkit = Toolkit()
toolkit.register_tool_function(execute_python_code)

Expand All @@ -167,21 +160,22 @@ async def query_func(
formatter=DashScopeChatFormatter(),
)

if state:
agent.load_state_dict(state)
await self.session.load_session_state(
session_id=session_id,
user_id=user_id,
agent=agent,
)

async for msg, last in stream_printing_messages(
agents=[agent],
coroutine_task=agent(msgs),
):
yield msg, last

state = agent.state_dict()

await self.state_service.save_state(
user_id=user_id,
await self.session.save_session_state(
session_id=session_id,
state=state,
user_id=user_id,
agent=agent,
)


Expand Down
Loading
Loading