agentscope-ai / agentscope-ai/agentscope-runtime

[Feature] AgentApp Websocket endpoint registration

Aperta
#327 1 commento 0 reazioni 2 assegnatari Rivendicata da @zzhangpurdue Vedi su GitHub
enhancement
Lingua principale
Python
Stelle
863
Fork
168
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

## 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]

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.