mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2026-02-15 17:16:57 +00:00
B FastembedAPI: Move to more appropriate folder
This commit is contained in:
parent
e142ea400a
commit
dd48810186
3 changed files with 0 additions and 0 deletions
8
supplemental/search/fastembed-api/Dockerfile
Normal file
8
supplemental/search/fastembed-api/Dockerfile
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
FROM python:3.9
|
||||
|
||||
WORKDIR /code
|
||||
COPY fastembed-server.py /workdir/fastembed-server.py
|
||||
|
||||
RUN pip install --no-cache-dir --upgrade fastembed fastapi uvicorn
|
||||
|
||||
CMD ["python", "/workdir/fastembed-server.py"]
|
||||
5
supplemental/search/fastembed-api/compose.yml
Normal file
5
supplemental/search/fastembed-api/compose.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
services:
|
||||
web:
|
||||
build: .
|
||||
ports:
|
||||
- "11345:11345"
|
||||
23
supplemental/search/fastembed-api/fastembed-server.py
Normal file
23
supplemental/search/fastembed-api/fastembed-server.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
from fastembed import TextEmbedding
|
||||
from fastapi import FastAPI
|
||||
from pydantic import BaseModel
|
||||
|
||||
models = {}
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
class EmbeddingRequest(BaseModel):
|
||||
model: str
|
||||
input: str
|
||||
|
||||
@app.post("/v1/embeddings")
|
||||
def embeddings(request: EmbeddingRequest):
|
||||
model = models.get(request.model) or TextEmbedding(request.model)
|
||||
models[request.model] = model
|
||||
embeddings = next(model.embed(request.input)).tolist()
|
||||
return {"data": [{"embedding": embeddings}]}
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
|
||||
uvicorn.run(app, host="0.0.0.0", port=11345)
|
||||
Loading…
Add table
Add a link
Reference in a new issue