Skip to content

Commit

Permalink
fix(embeddings): check context length
Browse files Browse the repository at this point in the history
  • Loading branch information
leoguillaumegouv committed Oct 3, 2024
1 parent 6f81c6a commit d7fc5ba
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions app/endpoints/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ async def embeddings(request: EmbeddingsRequest, user: User = Security(check_api
url = f"{client.base_url}embeddings"
headers = {"Authorization": f"Bearer {client.api_key}"}

if not client.check_context_length(model=request["model"], messages=request["messages"]):
raise HTTPException(status_code=400, detail="Context length too large")
# @TODO add check length ?

async with httpx.AsyncClient(timeout=20) as async_client:
response = await async_client.request(method="POST", url=url, headers=headers, json=request)
Expand Down

0 comments on commit d7fc5ba

Please sign in to comment.