chore: initialize sandbox and overwrite remote content
Some checks failed
Pre-commit / run (ubuntu-latest) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_en (ubuntu-latest, 3.10) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_zh (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.12) (push) Has been cancelled
Some checks failed
Pre-commit / run (ubuntu-latest) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_en (ubuntu-latest, 3.10) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_zh (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.12) (push) Has been cancelled
This commit is contained in:
20
examples/agent/voice_agent/README.md
Normal file
20
examples/agent/voice_agent/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Voice Agent
|
||||
|
||||
> This is experimental functionality in AgentScope.
|
||||
|
||||
This example demonstrates how to create a voice agent using AgentScope with Qwen-Omni model, featuring both text and audio output capabilities.
|
||||
|
||||
> **Note**:
|
||||
> - Qwen-Omni may not generate tool calls when the audio output is enabled.
|
||||
> - This example supports DashScope `Qwen-Omni` and OpenAI `GPT-4o Audio` models. You can change model by modifying the `model` parameter in `main.py`.
|
||||
> - We haven't tested vLLM yet. Contributions are welcome!
|
||||
|
||||
## Quick Start
|
||||
|
||||
Ensure you have installed agentscope and set ``DASHSCOPE_API_KEY`` in your environment variables.
|
||||
|
||||
Run the following commands to set up and run the example:
|
||||
|
||||
```bash
|
||||
python main.py
|
||||
```
|
||||
50
examples/agent/voice_agent/main.py
Normal file
50
examples/agent/voice_agent/main.py
Normal file
@@ -0,0 +1,50 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
A ReAct agent example that demonstrates audio output capability.
|
||||
Note: When audio output is enabled, tool calling functionality may be disabled.
|
||||
"""
|
||||
import asyncio
|
||||
import os
|
||||
from agentscope.agent import ReActAgent, UserAgent
|
||||
from agentscope.formatter import OpenAIChatFormatter
|
||||
|
||||
from agentscope.memory import InMemoryMemory
|
||||
from agentscope.model import OpenAIChatModel
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
"""The main entry point for the ReAct audio agent example."""
|
||||
|
||||
agent = ReActAgent(
|
||||
name="Friday",
|
||||
sys_prompt="You are a helpful assistant",
|
||||
model=OpenAIChatModel(
|
||||
model_name="qwen3-omni-flash",
|
||||
client_kwargs={
|
||||
"base_url": "https://dashscope.aliyuncs.com/"
|
||||
"compatible-mode/v1",
|
||||
},
|
||||
api_key=os.getenv("DASHSCOPE_API_KEY"),
|
||||
stream=True,
|
||||
# More options can be found in the DashScope API docs:
|
||||
# https://help.aliyun.com/zh/model-studio/qwen-omni
|
||||
generate_kwargs={
|
||||
"modalities": ["text", "audio"],
|
||||
"audio": {"voice": "Cherry", "format": "wav"},
|
||||
},
|
||||
),
|
||||
formatter=OpenAIChatFormatter(),
|
||||
memory=InMemoryMemory(),
|
||||
)
|
||||
|
||||
user = UserAgent("Bob")
|
||||
|
||||
msg = None
|
||||
while True:
|
||||
msg = await user(msg)
|
||||
if msg.get_text_content() == "exit":
|
||||
break
|
||||
msg = await agent(msg)
|
||||
|
||||
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user