agentscope-ai / agentscope-ai/agentscope-runtime

[Feature] AgentApp Websocket endpoint registration

Abierto
#327 1 comentario 0 reacciones 2 asignados Reclamado por @zzhangpurdue Ver en GitHub
enhancement
Lenguaje dominante
Python
Estrellas
863
Forks
168
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

## Problem Description
I want to create self-defined websocket endpoint using AgentApp just like in FastAPI. However, websocket decorator is not implemented so far.

## Proposed Solution
# 在 AgentApp 类中添加:

def websocket(self, path: str):
"""Decorator to register custom websocket endpoints"""
def decorator(func: Callable):
endpoint_info = {
"path": path,
"handler": func,
"methods": ["WS"], # 标记为 WebSocket 类型
"module": getattr(func, "__module__", None),
"function_name": getattr(func, "__name__", None),
"is_websocket": True, # 显式标记
}
self.custom_endpoints.append(endpoint_info)
return func

return decorator

## Affected Component(s)
- [x] Engine
- [ ] Sandbox
- [ ] Common
- [ ] Tools
- [x] Documentation
- [ ] Other: ___________

## Alternatives Considered
[Describe any alternative solutions you've considered]

## Additional Context
[Any other context, screenshots, or examples about the feature request]

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.