Skip to content

Commit

Permalink
Add server to norecursedirs, add doctstring for the endpoint method
Browse files Browse the repository at this point in the history
  • Loading branch information
NohTow committed Oct 2, 2024
1 parent 24ff544 commit bf113d7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/documentation/server.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Serve the embeddings of a PyLate model
The ```server.py``` script allows to create a FastAPI server to serve the embeddings of a PyLate model.
The ```server.py``` script (located in the ```server``` folder) allows to create a FastAPI server to serve the embeddings of a PyLate model.
To use it, you need to install the api dependencies: ```pip install "pylate[api]"```
Then, run ```python server.py``` to launch the server.

Expand Down
7 changes: 7 additions & 0 deletions pylate/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ def parse_args():

@app.post("/v1/embeddings", response_model=EmbeddingResponse)
async def create_embedding(request: EmbeddingRequest):
"""API endpoint that encode the elements of an EmbeddingRequest and returns an EmbeddingResponse.
Parameters
----------
request
The EmbeddingRequest containing the elements to encode, the model to use, and whether the input is a query or a document.
"""
if request.model != args.model:
raise HTTPException(
status_code=400,
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ norecursedirs =
build
docs
node_modules
pylate/server
markers =
web: tests that require using the Internet
slow: tests that take a long time to run

0 comments on commit bf113d7

Please sign in to comment.