Fixed CORS and proxy timeout issues

This commit is contained in:
SwiftyOS
2023-09-28 11:39:15 +02:00
parent ca65dfc4fa
commit 5360313271
2 changed files with 6 additions and 2 deletions

View File

@@ -47,9 +47,11 @@ class Agent:
"http://127.0.0.1:5000",
"http://localhost:8000",
"http://127.0.0.1:8000",
"http://localhost:8080",
"http://127.0.0.1:8080",
# Add any other origins you want to whitelist
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,

View File

@@ -119,6 +119,7 @@ updates_list = []
import json
origins = [
"http://localhost:8000",
"http://localhost:8080",
"http://127.0.0.1:5000",
"http://localhost:5000",
@@ -312,7 +313,8 @@ async def create_agent_task(task_eval_request: TaskEvalRequestBody) -> Task:
@router.post("/agent/tasks/{task_id}/steps")
async def proxy(request: Request, task_id: str):
async with httpx.AsyncClient() as client:
timeout = httpx.Timeout(300.0, read=300.0) # 5 minutes
async with httpx.AsyncClient(timeout=timeout) as client:
# Construct the new URL
new_url = f"http://localhost:8000/ap/v1/agent/tasks/{task_id}/steps"