From 98880688506f5331d1b38c76a1250d47f38482a9 Mon Sep 17 00:00:00 2001 From: Hemang Date: Thu, 30 Jan 2025 16:34:21 +0100 Subject: [PATCH] Update comments and rename files. Add anthropic.py for Anthropic API proxy. --- proxy/routes/anthropic.py | 5 +++++ proxy/routes/{proxy.py => open_ai.py} | 4 ++-- proxy/serve.py | 7 +++++-- 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 proxy/routes/anthropic.py rename proxy/routes/{proxy.py => open_ai.py} (96%) diff --git a/proxy/routes/anthropic.py b/proxy/routes/anthropic.py new file mode 100644 index 0000000..6e1f61b --- /dev/null +++ b/proxy/routes/anthropic.py @@ -0,0 +1,5 @@ +"""Proxy service to forward requests to the Anthropic APIs""" + +from fastapi import APIRouter + +proxy = APIRouter() diff --git a/proxy/routes/proxy.py b/proxy/routes/open_ai.py similarity index 96% rename from proxy/routes/proxy.py rename to proxy/routes/open_ai.py index dddbce3..8cd3b80 100644 --- a/proxy/routes/proxy.py +++ b/proxy/routes/open_ai.py @@ -1,4 +1,4 @@ -"""Proxy service to forward requests to the appropriate language model provider""" +"""Proxy service to forward requests to the OpenAI APIs""" import gzip import json @@ -47,7 +47,7 @@ async def openai_proxy( dataset_name: str, endpoint: str, ): - """Proxy call to a language model provider""" + """Proxy calls to the OpenAI APIs""" if endpoint not in ALLOWED_OPEN_AI_ENDPOINTS: raise HTTPException(status_code=404, detail=NOT_SUPPORTED_ENDPOINT) diff --git a/proxy/serve.py b/proxy/serve.py index 11e5aa2..dd997e2 100644 --- a/proxy/serve.py +++ b/proxy/serve.py @@ -2,13 +2,16 @@ import fastapi import uvicorn -from routes.proxy import proxy +from routes.anthropic import proxy as anthropic_proxy +from routes.open_ai import proxy as open_ai_proxy app = fastapi.FastAPI() router = fastapi.APIRouter(prefix="/api/v1") -router.include_router(proxy, prefix="/proxy", tags=["proxy"]) +router.include_router(open_ai_proxy, prefix="/proxy", tags=["open_ai_proxy"]) + +router.include_router(anthropic_proxy, prefix="/proxy", tags=["anthropic_proxy"]) app.include_router(router)