diff --git a/app/controller/add_test_route.py b/app/controller/add_test_route.py index b728364..7845376 100644 --- a/app/controller/add_test_route.py +++ b/app/controller/add_test_route.py @@ -1,3 +1,7 @@ +import asyncio +import os +import time + from fastapi import FastAPI from langchain.chat_models import init_chat_model from langserve import add_routes @@ -34,3 +38,22 @@ def add_test_route(app: FastAPI): ) add_routes(app=app, runnable=model, path="/doubao") + + @app.get("/test") + async def test(): + print(f"Process {os.getpid()} handling /test") + return {"message": "Hello World"} + + @app.get("/sync_delay") + async def sync_delay(delay: int = 1): + """同步延迟delay秒""" + print(f"Process {os.getpid()} handling /sync_delay") + time.sleep(delay) + return {"hello": "world"} + + @app.get("/async_delay") + async def async_delay(delay: int = 1): + """异步延迟delay秒""" + print(f"Process {os.getpid()} handling /async_delay") + await asyncio.sleep(delay) + return {"hello": "world"}