agentscope-ai / agentscope-ai/agentscope-runtime

[Feature] AgentApp Websocket endpoint registration

Offen
#327 1 Kommentar 0 Reaktionen 2 zugewiesene Personen Beansprucht von @zzhangpurdue Auf GitHub ansehen
enhancement
Vorherrschende Sprache
Python
Sterne
863
Forks
168
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.