ChatController
@RestController @RequestMapping("/api") @CrossOrigin(origins = "*") public class ChatController
源码Source
io/agentscope/examples/chattts/ChatController.java:50–215聊天控制器,处理低延迟的实时语音与多模态交互。位于 io.agentscope.examples.chattts 包。核心成员包括 chat、ChatController。
Chat controller with real-time TTS streaming.
Provides SSE endpoint that streams both text and audio to frontend:
-
event: "text" - LLM generated text chunks
-
event: "audio" - Base64 encoded audio chunks
-
event: "done" - Stream completed
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public ChatController() | 创建新的ChatController。 Creates a new ChatController. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Flux<ServerSentEvent<Map<String, Object>>> chat(Map<String, String> request) | 设置聊天。 Chat endpoint with real-time TTS. |
构造器详情Constructor Detail
ChatController
public ChatController()
创建新的ChatController。
Creates a new ChatController.
IllegalStateException当if DashScope_API_密钥是不设置时抛出 `IllegalStateException`。if DASHSCOPE_API_KEY is not set
源码Source
io/agentscope/examples/chattts/ChatController.java:65–73方法详情Method Detail
chat
public Flux<ServerSentEvent<Map<String, Object>>> chat(Map<String, String> request)
设置聊天。
Chat endpoint with real-time TTS.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
request | Map<String, String> | 请求(类型 `Map`)。containing "message" field |
Flux<ServerSentEvent<Map<String, Object>>>文本和音频的SSE 流。SSE stream of text and audio
源码Source
io/agentscope/examples/chattts/ChatController.java:93–214