-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathembeddings.py
More file actions
33 lines (27 loc) · 842 Bytes
/
embeddings.py
File metadata and controls
33 lines (27 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from fastapi import APIRouter, Request, Depends
from backend.middleware.auth import require_auth
from backend.services.llm_service import llm_proxy_embeddings
from backend.config import get_settings
router = APIRouter()
settings = get_settings()
@router.post("/v1/embeddings")
async def embeddings(
request: Request,
token: str = Depends(require_auth),
):
data = await request.json()
data["user_id"] = token
opt_out = request.headers.get("X-OPTOUT-TRACKING", "").lower() in (
"true",
"1",
"yes",
)
app_title = request.headers.get("X-Title", "")
data["opt_out"] = opt_out
data["app_title"] = app_title
response = await llm_proxy_embeddings(
endpoint=settings.otela_head_addr + "/v1/service/llm/v1/",
api_key=token,
**data,
)
return response