Skip to content

Build and run agents you can see, understand and trust.

Add fanout pipeline into the tutorial of agentscope (#700)

qbc0fdaf3811be1
diff --git a/docs/tutorial/en/src/task_model.py b/docs/tutorial/en/src/task_model.py
index 8c8bdc3ac..4218032c7 100644
--- a/docs/tutorial/en/src/task_model.py
+++ b/docs/tutorial/en/src/task_model.py
@@ -54,6 +54,8 @@ The supported model APIs and providers include:
- ✅
- ✅
+.. note:: When using vLLM, you need to configure the appropriate tool calling parameters for different models during deployment, such as ``--enable-auto-tool-choice``, ``--tool-call-parser``, etc. For more details, refer to the `official vLLM documentation <https://docs.vllm.ai/en/latest/features/tool_calling.html>`_.
+
To provide unified model interfaces, the above model classes has the following common methods:
- The first three arguments of the ``__call__`` method are ``messages`` , ``tools`` and ``tool_choice``, representing the input messages, JSON schema of tool functions, and tool selection mode, respectively.
diff --git a/docs/tutorial/en/src/task_pipeline.py b/docs/tutorial/en/src/task_pipeline.py
index 39d002e05..55f1f9971 100644
--- a/docs/tutorial/en/src/task_pipeline.py
+++ b/docs/tutorial/en/src/task_pipeline.py
@@ -10,6 +10,7 @@ as syntax sugar for chaining agents together, including
- **MsgHub**: a message hub for broadcasting messages among multiple agents
- **sequential_pipeline** and **SequentialPipeline**: a functional and class-based implementation that chains agents in a sequential manner
+- **fanout_pipeline** and **FanoutPipeline**: a functional and class-based implementation that distributes the same input to multiple agents
"""
@@ -87,7 +88,7 @@ asyncio.run(example_broadcast_message())
async def check_broadcast_message():
- """Check if the messages are broadcasted correctly."""
+ """Check if the messages are broadcast correctly."""
user_msg = Msg(
"user",
"Do you know who's Alice, and what she does? Answer me briefly.",
@@ -135,8 +136,16 @@ asyncio.run(check_broadcast_message())
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Pipeline serves as a syntax sugar for multi-agent orchestration.
#
-# Currently, AgentScope provides a sequential pipeline implementation, which
-# execute agents one by one in a predefined order.
+# Currently, AgentScope provides two main pipeline implementations:
+#
+# 1. **Sequential Pipeline**: Execute agents one by one in a predefined order
+# 2. **Fanout Pipeline**: Distribute the same input to multiple agents and collect their responses
+#
+# Sequential Pipeline
+# ------------------------
+# The sequential pipeline executes agents one by one, where the output of the previous agent
+# becomes the input of the next agent.
+#
# For example, the two following code snippets are equivalent:
#
#
@@ -161,8 +170,52 @@ asyncio.run(check_broadcast_message())
# msg=None
# )
#
-# .. tip:: By combining `MsgHub` and `sequential_pipeline`, you can create more complex workflows very easily.
+
+# %%
+# Fanout Pipeline
+# ------------------------
+# The fanout pipeline distributes the same input message to multiple agents simultaneously and collects all their responses. This is useful when you want to gather different perspectives or expertise on the same topic.
+#
+# For example, the two following code snippets are equivalent:
+#
+#
+# .. code-block:: python
+# :caption: Code snippet 3: Manually call agents one by one
+#
+# from copy import deepcopy
#
+# msgs = []
+# msg = None
+# for agent in [alice, bob, charlie, david]:
+# msgs.append(await agent(deepcopy(msg)))
+#
+#
+# .. code-block:: python
+# :caption: Code snippet 4: Use fanout pipeline
+#
+# from agentscope.pipeline import fanout_pipeline
+# msgs = await fanout_pipeline(
+# # List of agents to be executed in order
+# agents=[alice, bob, charlie, david],
+# # The first input message, can be None
+# msg=None,
+# enable_gather=False,
+# )
+#
+# .. note::
+# The ``enable_gather`` parameter controls the execution mode of the fanout pipeline:
+#
+# - ``enable_gather=True`` (default): Executes all agents **concurrently** using ``asyncio.gather()``. This provides better performance for I/O-bound operations like API calls, as agents run in parallel.
+# - ``enable_gather=False``: Executes agents **sequentially** one by one. This is useful when you need deterministic execution order or want to avoid overwhelming external services with concurrent requests.
+#
+# Choose concurrent execution for better performance, or sequential execution for predictable ordering and resource control.
+#
+# .. tip::
+# By combining ``MsgHub`` and ``sequential_pipeline`` or ``fanout_pipeline``, you can create more complex workflows very easily.
+
+# %%
+# Advanced Pipeline Features
+# ~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Additionally, for reusability, we also provide a class-based implementation:
#
@@ -181,3 +234,17 @@ asyncio.run(check_broadcast_message())
# msg = await pipeline(msg=Msg("user", "Hello!", "user"))
#
#
+# .. code-block:: python
+# :caption: Using FanoutPipeline class
+#
+# from agentscope.pipeline import FanoutPipeline
+#
+# # Create a pipeline object
+# pipeline = FanoutPipeline(agents=[alice, bob, charlie, david])
+#
+# # Call the pipeline
+# msgs = await pipeline(msg=None)
+#
+# # Reuse the pipeline with different input
+# msgs = await pipeline(msg=Msg("user", "Hello!", "user"))
+#
diff --git a/docs/tutorial/zh_CN/src/task_model.py b/docs/tutorial/zh_CN/src/task_model.py
index 2f1ca5e04..8eb74f035 100644
--- a/docs/tutorial/zh_CN/src/task_model.py
+++ b/docs/tutorial/zh_CN/src/task_model.py
@@ -54,6 +54,8 @@ AgentScope 目前支持的模型 API 和模型提供商包括:
- ✅
- ✅
+.. note:: 当使用 vLLM 时,您需要在部署时为不同模型配置相应的工具调用参数,例如 ``--enable-auto-tool-choice``、``--tool-call-parser`` 等参数。更多详情请参考 `vLLM 官方文档 <https://docs.vllm.ai/en/latest/features/tool_calling.html>`_。
+
为了提供统一的模型接口,上述所有类均被统一为:
- ``__call__`` 函数的前三个参数是 ``messages``,``tools`` 和 ``tool_choice``,分别是输入消息,工具函数的 JSON schema,以及工具选择的模式。
diff --git a/docs/tutorial/zh_CN/src/task_pipeline.py b/docs/tutorial/zh_CN/src/task_pipeline.py
index d560f63aa..97667f828 100644
--- a/docs/tutorial/zh_CN/src/task_pipeline.py
+++ b/docs/tutorial/zh_CN/src/task_pipeline.py
@@ -9,7 +9,8 @@
作为将智能体链接在一起的语法糖,具体包括
- **MsgHub**: 用于多个智能体之间消息的广播
-- **sequential_pipeline** 和 **SequentialPipeline**: 以顺序方式执行多个智能体
+- **sequential_pipeline** 和 **SequentialPipeline**: 以顺序方式执行多个智能体的函数式和类式实现
+- **fanout_pipeline** 和 **FanoutPipeline**: 将相同输入分发给多个智能体的函数式和类式实现
"""
@@ -97,6 +98,8 @@ async def check_broadcast_message():
await david(user_msg)
+asyncio.run(check_broadcast_message())
+
# %%
# 现在我们观察到 Bob 和 Charlie 知道 Alice 和她的职业,而 David 对
# Alice 一无所知,因为他没有包含在 ``MsgHub`` 上下文中。
@@ -131,7 +134,15 @@ async def check_broadcast_message():
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 管道是 AgentScope 中多智能体编排的一种语法糖。
#
-# 目前,AgentScope 提供了一个顺序管道实现,它按预定义的顺序逐个执行智能体。
+# 目前,AgentScope 提供了两种主要的管道实现:
+#
+# 1. **顺序管道 (Sequential Pipeline)**: 按预定义顺序逐个执行智能体
+# 2. **扇出管道 (Fanout Pipeline)**: 将相同输入分发给多个智能体并收集它们的响应
+#
+# 顺序管道
+# ------------------------
+# 顺序管道逐个执行智能体,前一个智能体的输出成为下一个智能体的输入。
+#
# 例如,以下两个代码片段是等价的:
#
# .. code-block:: python
@@ -156,8 +167,52 @@ async def check_broadcast_message():
# msg=None
# )
#
-# .. tip:: 通过结合 `MsgHub` 和 `sequential_pipeline`,你可以非常容易地创建更复杂的工作流。
+
+# %%
+# 扇出管道
+# ------------------------
+# 扇出管道将相同的输入消息同时分发给多个智能体并收集所有响应。当你想要收集对同一话题的不同观点或专业意见时,这非常有用。
+#
+# 例如,以下两个代码片段是等价的:
+#
+# .. code-block:: python
+# :caption: 代码片段 3: 手动逐个调用智能体
+#
+# from copy import deepcopy
+#
+# msgs = []
+# msg = None
+# for agent in [alice, bob, charlie, david]:
+# msgs.append(await agent(deepcopy(msg)))
+#
+#
+# .. code-block:: python
+# :caption: 代码片段 4: 使用扇出管道
+#
+# from agentscope.pipeline import fanout_pipeline
+#
+# msgs = await fanout_pipeline(
+# # 要执行的智能体列表
+# agents=[alice, bob, charlie, david],
+# # 输入消息,可以是 None
+# msg=None,
+# enable_gather=False,
+# )
+#
+# .. note::
+# ``enable_gather`` 参数控制扇出管道的执行模式:
+#
+# - ``enable_gather=True`` (默认): 使用 ``asyncio.gather()`` **并发** 执行所有智能体。这为 I/O 密集型操作(如 API 调用)提供更好的性能,因为智能体并行运行。
+# - ``enable_gather=False``: 逐个 **顺序** 执行智能体。当你需要确定性的执行顺序或想要避免并发请求压垮外部服务时,这很有用。
#
+# 选择并发执行以获得更好的性能,或选择顺序执行以获得可预测的顺序和资源控制。
+#
+# .. tip::
+# 通过结合 ``MsgHub`` 和 ``sequential_pipeline`` 或 ``fanout_pipeline``,你可以非常容易地创建更复杂的工作流。
+
+# %%
+# 高级管道特性
+# ~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 此外,为了可重用性,我们还提供了基于类的实现:
#
@@ -176,3 +231,17 @@ async def check_broadcast_message():
# msg = await pipeline(msg=Msg("user", "你好!", "user"))
#
#
+# .. code-block:: python
+# :caption: 使用 FanoutPipeline 类
+#
+# from agentscope.pipeline import FanoutPipeline
+#
+# # 创建管道对象
+# pipeline = FanoutPipeline(agents=[alice, bob, charlie, david])
+#
+# # 调用管道
+# msgs = await pipeline(msg=None)
+#
+# # 使用不同输入复用管道
+# msgs = await pipeline(msg=Msg("user", "你好!", "user"))
+#
diff --git a/examples/agent_deep_research/README.md b/examples/agent_deep_research/README.md
index 04151d838..c0a8c6228 100644
--- a/examples/agent_deep_research/README.md
+++ b/examples/agent_deep_research/README.md
@@ -41,34 +41,6 @@ tavily_search_client= StdIOStatefulClient(
await tavily_search_client.connect()
```
-## Replace the Model and Formatter
-AgentScope provides several built-in model implementations that you can easily switch between. You can also implement your own custom model if needed.
-
-For example, to use the OpenAI model, you can replace the model and formatter as follows:
-```
-from agentscope.model import OpenAIChatModel
-from agentscope.formatter import OpenAIChatFormatter
-
-# Replace the model and formatter with:
-agent = DeepResearchAgent(
- name="Friday",
- sys_prompt="You are a helpful assistant named Friday.",
- model=OpenAIChatModel(
- api_key=os.environ.get("OPENAI_API_KEY"),
- model_name="gpt-4",
- stream=True,
- ),
- formatter=OpenAIChatFormatter(), # Use matching formatter
- memory=InMemoryMemory(),
- search_mcp_client=tavily_search_client,
- tmp_file_storage_dir=agent_working_dir,
-)
-```
-
-## Notes
-
-⚠️ Formatter Compatibility: Always use the formatter that matches your model. Mismatched formatters can cause communication errors between the agent and the model.
-
-🔧 Tool Usage: Ensure your chosen model supports function calling capabilities to maintain full ReAct functionality with tool usage.
-
-🏠 Local Models: For local models, ensure the model service (like Ollama) is running before starting the agent.
\ No newline at end of file
+> Note: The example is built with DashScope chat model. If you want to change the model in this example, don't forget
+> to change the formatter at the same time! The corresponding relationship between built-in models and formatters are
+> list in [our tutorial](https://doc.agentscope.io/tutorial/task_prompt.html#id1)
diff --git a/examples/react_agent/README.md b/examples/react_agent/README.md
index a5e780b1e..a5dabddbd 100644
--- a/examples/react_agent/README.md
+++ b/examples/react_agent/README.md
@@ -1,63 +1,22 @@
# ReAct Agent Example
-## What This Example Demonstrates
+This example showcases a **ReAct** agent in AgentScope. Specifically, the ReAct agent will discuss with the user in
+an alternative manner, i.e., chatbot style. It is equipped with a suite of tools to assist in answering user queries.
-This example showcases a **ReAct Agent** implementation using the
-AgentScope framework. The ReAct agent combines reasoning and action capabilities to solve complex tasks through iterative thought processes and tool usage.
+> 💡 Tip: Try ``Ctrl+C`` to interrupt the agent's reply to experience the realtime steering/interruption feature!
-### Key Features:
-- **Intelligent Assistant**: Creates an AI assistant named "Friday" that can think and act
-- **Tool Integration**: Equipped with practical tools including:
- - Shell command execution
- - Python code execution
- - Text file viewing
-- **Interactive Conversation**: Supports real-time conversation between user and agent
-- **Streaming Response**: Enables real-time response streaming for better user experience
-- **Memory Management**: Maintains conversation context using in-memory storage
+## Quick Start
-The agent follows the ReAct paradigm, where it can:
-1. **Reason** about the user's request
-2. **Act** by using available tools when necessary
-3. **Observe** the results and continue reasoning
-4. **Respond** with helpful information or actions
+Ensure you have installed agentscope and set ``DASHSCOPE_API_KEY`` in your environment variables.
-## How to Run This Example
-1. **Set Environment Variable**:
- ```bash
- export DASHSCOPE_API_KEY="your_dashscope_api_key_here"
- ```
-2. Run the script:
- ```bash
- python main.py
- ```
+Run the following commands to set up and run the example:
-## Replace the Model and Formatter
-AgentScope provides several built-in model implementations that you can easily switch between. You can also implement your own custom model if needed.
-
-For example, to use the OpenAI model, you can replace the model and formatter as follows:
-```
-from agentscope.model import OpenAIChatModel
-from agentscope.formatter import OpenAIChatFormatter
-
-# Replace the model and formatter with:
-agent = ReActAgent(
- name="Friday",
- sys_prompt="You are a helpful assistant named Friday.",
- model=OpenAIChatModel(
- api_key=os.environ.get("OPENAI_API_KEY"),
- model_name="gpt-4",
- stream=True,
- ),
- formatter=OpenAIChatFormatter(), # Use matching formatter
- toolkit=toolkit,
- memory=InMemoryMemory(),
-)
+```bash
+python main.py
```
-## Notes
-
-⚠️ Formatter Compatibility: Always use the formatter that matches your model. Mismatched formatters can cause communication errors between the agent and the model.
-
-🔧 Tool Usage: Ensure your chosen model supports function calling capabilities to maintain full ReAct functionality with tool usage.
-
-🏠 Local Models: For local models, ensure the model service (like Ollama) is running before starting the agent.
\ No newline at end of file
+> Note:
+> - The example is built with DashScope chat model. If you want to change the model used in this example, don't
+> forget to change the formatter at the same time! The corresponding relationship between built-in models and
+> formatters are list in [our tutorial](https://doc.agentscope.io/tutorial/task_prompt.html#id1)
+> - For local models, ensure the model service (like Ollama) is running before starting the agent.
diff --git a/examples/workflows/multiagent_conversation/README.md b/examples/workflows/multiagent_conversation/README.md
index a712d1f9a..ab1b4955a 100644
--- a/examples/workflows/multiagent_conversation/README.md
+++ b/examples/workflows/multiagent_conversation/README.md
@@ -18,3 +18,7 @@ python examples/workflows/multiagent_conversation/main.py
- Create multiple participant agents with different attributes (e.g., Alice, Bob, Charlie).
- Agents introduce themselves and interact in the message hub.
- Supports dynamic addition and removal of agents, as well as broadcasting messages.
+
+> Note: The example is built with DashScope chat model. If you want to change the model in this example, don't forget
+> to change the formatter at the same time! The corresponding relationship between built-in models and formatters are
+> list in [our tutorial](https://doc.agentscope.io/tutorial/task_prompt.html#id1)
\ No newline at end of file
diff --git a/examples/workflows/multiagent_debate/README.md b/examples/workflows/multiagent_debate/README.md
index 2b8190efd..56d68c86d 100644
--- a/examples/workflows/multiagent_debate/README.md
+++ b/examples/workflows/multiagent_debate/README.md
@@ -17,3 +17,8 @@ To run the example, first install the latest version of AgentScope, then run:
```bash
python examples/workflows/multiagent_debate/main.py
```
+
+
+> Note: The example is built with DashScope chat model. If you want to change the model in this example, don't forget
+> to change the formatter at the same time! The corresponding relationship between built-in models and formatters are
+> list in [our tutorial](https://doc.agentscope.io/tutorial/task_prompt.html#id1)
\ No newline at end of file
diff --git a/src/agentscope/tool/_multi_modality/_dashscope_tools.py b/src/agentscope/tool/_multi_modality/_dashscope_tools.py
index 8fba22436..cc8861599 100644
--- a/src/agentscope/tool/_multi_modality/_dashscope_tools.py
+++ b/src/agentscope/tool/_multi_modality/_dashscope_tools.py
@@ -45,8 +45,8 @@ def dashscope_text_to_image(
Returns:
`ToolResponse`:
A ToolResponse containing the generated content
- (ImageBlock/TextBlock/AudioBlock) or error information if the
- operation failed.
+ (ImageBlock/TextBlock/AudioBlock) or error information if the
+ operation failed.
"""
try:
import dashscope
@@ -135,8 +135,8 @@ def dashscope_image_to_text(
Returns:
`ToolResponse`:
A ToolResponse containing the generated content
- (ImageBlock/TextBlock/AudioBlock) or error information if the
- operation failed.
+ (ImageBlock/TextBlock/AudioBlock) or error information if the
+ operation failed.
"""
if isinstance(image_urls, str):
@@ -240,16 +240,17 @@ def dashscope_text_to_audio(
api_key (`str`):
The api key for the dashscope API.
model (`str`, defaults to 'sambert-zhichu-v1'):
- The model to use. Full model list can be found in
- https://help.aliyun.com/zh/dashscope/model-list
+ The model to use. Full model list can be found in the
+ `official document
+ <https://help.aliyun.com/zh/model-studio/sambert-python-sdk>`_.
sample_rate (`int`, defaults to 48000):
Sample rate of the audio.
Returns:
`ToolResponse`:
A ToolResponse containing the generated content
- (ImageBlock/TextBlock/AudioBlock) or error information if the
- operation failed.
+ (ImageBlock/TextBlock/AudioBlock) or error information if the
+ operation failed.
"""
try:
diff --git a/src/agentscope/tool/_multi_modality/_openai_tools.py b/src/agentscope/tool/_multi_modality/_openai_tools.py
index 0e210e297..2c77c4238 100644
--- a/src/agentscope/tool/_multi_modality/_openai_tools.py
+++ b/src/agentscope/tool/_multi_modality/_openai_tools.py
@@ -75,16 +75,16 @@ def openai_text_to_image(
size (`Literal["256x256", "512x512", "1024x1024", "1792x1024", \
"1024x1792"]`, defaults to `"256x256"`):
The size of the generated images.
- Must be one of 1024x1024, 1536x1024 (landscape), 1024x1536 (
- portrait), or auto (default value) for gpt-image-1,
- one of 256x256, 512x512, or 1024x1024 for dall-e-2,
- and one of 1024x1024, 1792x1024, or 1024x1792 for dall-e-3.
+ Must be one of 1024x1024, 1536x1024 (landscape), 1024x1536 (
+ portrait), or auto (default value) for gpt-image-1,
+ one of 256x256, 512x512, or 1024x1024 for dall-e-2,
+ and one of 1024x1024, 1792x1024, or 1024x1792 for dall-e-3.
quality (`Literal["auto", "standard", "hd", "high", "medium", \
"low"]`, defaults to `"auto"`):
The quality of the image that will be generated.
- `auto` (default value) will automatically select the best
- quality for the given model.
+ quality for the given model.
- `high`, `medium` and `low` are supported for gpt-image-1.
- `hd` and `standard` are supported for dall-e-3.
- `standard` is the only option for dall-e-2.
@@ -92,18 +92,20 @@ def openai_text_to_image(
The style of the generated images.
This parameter is only supported for dall-e-3.
Must be one of `vivid` or `natural`.
+
- `Vivid` causes the model to lean towards generating hyper-real
- and dramatic images.
+ and dramatic images.
- `Natural` causes the model to produce more natural,
- less hyper-real looking images.
+ less hyper-real looking images.
response_format (`Literal["url", "b64_json"]`, defaults to `"url"`):
The format in which generated images with dall-e-2 and dall-e-3
- are returned.
+ are returned.
+
- Must be one of "url" or "b64_json".
- URLs are only valid for 60 minutes after the image has been
- generated.
+ generated.
- This parameter isn't supported for gpt-image-1 which will always
- return base64-encoded images.
+ return base64-encoded images.
Returns:
`ToolResponse`:
A ToolResponse containing the generated content
@@ -212,16 +214,17 @@ def openai_edit_image(
The size of the edited images.
response_format (`Literal["url", "b64_json"]`, defaults to `"url"`):
The format in which generated images are returned.
- Must be one of "url" or "b64_json".
- URLs are only valid for 60 minutes after generation.
- This parameter isn't supported for gpt-image-1 which will
+
+ - Must be one of "url" or "b64_json".
+ - URLs are only valid for 60 minutes after generation.
+ - This parameter isn't supported for gpt-image-1 which will
always return base64-encoded images.
Returns:
`ToolResponse`:
A ToolResponse containing the generated content
- (ImageBlock/TextBlock/AudioBlock) or error information if the
- operation failed.
+ (ImageBlock/TextBlock/AudioBlock) or error information if the
+ operation failed.
"""
@@ -344,15 +347,16 @@ def openai_create_image_variation(
The size of the generated image variations.
response_format (`Literal["url", "b64_json"]`, defaults to `"url"`):
The format in which generated images are returned.
- Must be one of url or b64_json.
- URLs are only valid for 60 minutes after the image has been
- generated.
+
+ - Must be one of url or b64_json.
+ - URLs are only valid for 60 minutes after the image has been
+ generated.
Returns:
`ToolResponse`:
A ToolResponse containing the generated content
- (ImageBlock/TextBlock/AudioBlock) or error information if the
- operation failed.
+ (ImageBlock/TextBlock/AudioBlock) or error information if the
+ operation failed.
"""
# _parse_url handles both local and web URLs and returns BytesIO
@@ -434,8 +438,8 @@ def openai_image_to_text(
Returns:
`ToolResponse`:
A ToolResponse containing the generated content
- (ImageBlock/TextBlock/AudioBlock) or error information if the
- operation failed.
+ (ImageBlock/TextBlock/AudioBlock) or error information if the
+ operation failed.
"""
if isinstance(image_urls, str):
@@ -535,15 +539,14 @@ def openai_text_to_audio(
speed (`float`, defaults to `1.0`):
The speed of the audio playback. A value of 1.0 is normal speed.
res_format (`Literal["mp3", "wav", "opus", "aac", "flac", \
- "wav", "pcm"]`,
- defaults to `"mp3"`):
+ "wav", "pcm"]`, defaults to `"mp3"`):
The format of the audio file.
Returns:
`ToolResponse`:
A ToolResponse containing the generated content
- (ImageBlock/TextBlock/AudioBlock) or error information if the
- operation failed.
+ (ImageBlock/TextBlock/AudioBlock) or error information if the
+ operation failed.
"""
try:
@@ -612,8 +615,8 @@ def openai_audio_to_text(
Returns:
`ToolResponse`:
A ToolResponse containing the generated content
- (ImageBlock/TextBlock/AudioBlock) or error information if the
- operation failed.
+ (ImageBlock/TextBlock/AudioBlock) or error information if the
+ operation failed.
"""
try: