mirror of
https://github.com/invariantlabs-ai/invariant-gateway.git
synced 2026-07-09 20:28:36 +02:00
Remove u/ from the proxy api and some other changes for fastapi.
This commit is contained in:
@@ -10,8 +10,7 @@ services:
|
||||
- DEV_MODE=true
|
||||
networks:
|
||||
- invariant-explorer-web
|
||||
ports:
|
||||
- "8002:8000"
|
||||
ports: []
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.explorer-proxy-api.rule=(Host(`localhost`) && PathPrefix(`/api/v1/proxy/`)) || (Host(`127.0.0.1`) && PathPrefix(`/api/v1/proxy/`))"
|
||||
|
||||
@@ -6,4 +6,7 @@ WORKDIR /srv/proxy
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
COPY . /srv/proxy
|
||||
|
||||
# Ensure run.sh is executable
|
||||
RUN chmod +x /srv/proxy/run.sh
|
||||
|
||||
ENTRYPOINT ./run.sh
|
||||
@@ -1,2 +1,2 @@
|
||||
fastapi
|
||||
uvicorn
|
||||
fastapi==0.115.7
|
||||
uvicorn==0.34.0
|
||||
@@ -1,11 +1,11 @@
|
||||
"""Proxy service to forward requests to the appropriate language model provider"""
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi import APIRouter
|
||||
|
||||
proxy = FastAPI()
|
||||
proxy = APIRouter()
|
||||
|
||||
|
||||
@proxy.post("/u/{username}/{dataset_name}/{llm_provider}")
|
||||
@proxy.post("/{username}/{dataset_name}/{llm_provider}")
|
||||
async def chat_completion(username: str, dataset_name: str, llm_provider: str):
|
||||
"""Proxy call to a language model provider"""
|
||||
return {"message": f"Upload {dataset_name} for {username} to {llm_provider}"}
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
#/bin/bash
|
||||
#!/bin/bash
|
||||
|
||||
# if DEV_MODE is true, then run the app with auto-reload
|
||||
if [ "$DEV_MODE" = "true" ]; then
|
||||
uvicorn serve:proxy_app --host 0.0.0.0 --port 8000 --reload
|
||||
uvicorn serve:app --host 0.0.0.0 --port 8000 --reload
|
||||
else
|
||||
uvicorn serve:proxy_app --host 0.0.0.0 --port 8000
|
||||
uvicorn serve:app --host 0.0.0.0 --port 8000
|
||||
fi
|
||||
|
||||
+8
-9
@@ -2,17 +2,16 @@
|
||||
|
||||
import fastapi
|
||||
import uvicorn
|
||||
from proxy import proxy
|
||||
from routes.proxy import proxy
|
||||
|
||||
v1 = fastapi.FastAPI()
|
||||
app = fastapi.FastAPI()
|
||||
|
||||
# install the API routes
|
||||
v1.mount("/proxy", proxy)
|
||||
router = fastapi.APIRouter(prefix="/api/v1")
|
||||
|
||||
# mount the API under /api/v1
|
||||
proxy_app = fastapi.FastAPI()
|
||||
proxy_app.mount("/api/v1", v1)
|
||||
router.include_router(proxy, prefix="/proxy", tags=["proxy"])
|
||||
|
||||
# serve the API
|
||||
app.include_router(router)
|
||||
|
||||
# Serve the API
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run(proxy_app, host="0.0.0.0", port=8000)
|
||||
uvicorn.run(app, host="0.0.0.0", port=8000)
|
||||
|
||||
Reference in New Issue
Block a user