refactor: move session initialization from WebSocket to REST API (#5493)

Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: sp.wack <83104063+amanape@users.noreply.github.com>
This commit is contained in:
Robert Brennan
2024-12-20 10:50:09 -05:00
committed by GitHub
parent 0dd919bacf
commit 73c38f1163
48 changed files with 628 additions and 1442 deletions

View File

@@ -10,16 +10,16 @@ from fastapi import (
import openhands.agenthub # noqa F401 (we import this to get the agents registered)
from openhands.server.middleware import (
AttachSessionMiddleware,
AttachConversationMiddleware,
InMemoryRateLimiter,
LocalhostCORSMiddleware,
NoCacheMiddleware,
RateLimitMiddleware,
)
from openhands.server.routes.conversation import app as conversation_api_router
from openhands.server.routes.feedback import app as feedback_api_router
from openhands.server.routes.files import app as files_api_router
from openhands.server.routes.github import app as github_api_router
from openhands.server.routes.new_conversation import app as new_conversation_api_router
from openhands.server.routes.public import app as public_api_router
from openhands.server.routes.security import app as security_api_router
from openhands.server.routes.settings import app as settings_router
@@ -54,23 +54,13 @@ async def health():
app.include_router(public_api_router)
app.include_router(files_api_router)
app.include_router(conversation_api_router)
app.include_router(security_api_router)
app.include_router(feedback_api_router)
app.include_router(new_conversation_api_router)
app.include_router(settings_router)
app.include_router(github_api_router)
AttachSessionMiddlewareImpl = get_impl(
AttachSessionMiddleware, openhands_config.attach_session_middleware_path
)
app.middleware('http')(AttachSessionMiddlewareImpl(app, target_router=files_api_router))
app.middleware('http')(
AttachSessionMiddlewareImpl(app, target_router=conversation_api_router)
)
app.middleware('http')(
AttachSessionMiddlewareImpl(app, target_router=security_api_router)
)
app.middleware('http')(
AttachSessionMiddlewareImpl(app, target_router=feedback_api_router)
AttachConversationMiddlewareImpl = get_impl(
AttachConversationMiddleware, openhands_config.attach_conversation_middleware_path
)
app.middleware('http')(AttachConversationMiddlewareImpl(app))