INNER CODE UNIT · Python

endpoint

agentscope-ai/agentscope-runtime · src/agentscope_runtime/sandbox/manager/server/app.py:160

    async def endpoint(
        request: Request,
        token: HTTPAuthorizationCredentials = Depends(verify_token),
    ):
        try:
            data = await request.json()
            logger.info(
                f"Calling {method.__name__} with data: {data}",
            )

            # Check if the method is asynchronous
            if inspect.iscoroutinefunction(method):
                # If async, just await it
                result = await method(**data)
            else:
                # If sync, run it in a thread to avoid blocking the event loop
                result = await asyncio.to_thread(method, **data)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…