mirror of
https://github.com/frappe/gunicorn.git
synced 2026-07-01 18:21:30 +08:00
- Bump version to 25.0.2 - Update copyright year to 2026 in LICENSE and NOTICE - Add license headers to all Python source files - Add changelog entry for 25.0.2
34 lines
723 B
Python
34 lines
723 B
Python
#
|
|
# This file is part of gunicorn released under the MIT license.
|
|
# See the NOTICE for more information.
|
|
|
|
from fastapi import FastAPI
|
|
from pydantic import BaseModel
|
|
from gunicorn.dirty.client import get_dirty_client
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
class EmbedRequest(BaseModel):
|
|
texts: list[str]
|
|
|
|
|
|
class EmbedResponse(BaseModel):
|
|
embeddings: list[list[float]]
|
|
|
|
|
|
@app.post("/embed", response_model=EmbedResponse)
|
|
async def embed(request: EmbedRequest):
|
|
client = get_dirty_client()
|
|
result = client.execute(
|
|
"embedding_service.embedding_app:EmbeddingApp",
|
|
"embed",
|
|
request.texts
|
|
)
|
|
return EmbedResponse(embeddings=result)
|
|
|
|
|
|
@app.get("/health")
|
|
async def health():
|
|
return {"status": "ok"}
|