agentscope-ai / agentscope-ai/agentscope-runtime

[Feature] AgentApp Websocket endpoint registration

Aberta
#327 1 comentário 0 reações 2 responsáveis Reivindicada por @zzhangpurdue Ver no GitHub
enhancement
Linguagem predominante
Python
Estrelas
863
Forks
168
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.