File size: 665 Bytes
ca8bacf ed7f561 ca8bacf ed7f561 ca8bacf ed7f561 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
from fastapi import FastAPI
from sentence_transformers import SentenceTransformer
app = FastAPI()
all_MiniLM_L6_V2_model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
@app.get("/")
def greet_json():
return {"Hello": "World!"}
@app.post("/generate-embeddings/sentence-transformers-all-MiniLM-L6-v2/")
def generate_embeddings_model1(sentences: list, all_MiniLM_L6_V2_model):
sentences = [
"The weather is lovely today.",
"It's so sunny outside!",
"He drove to the stadium.",
]
embeddings = all_MiniLM_L6_V2_model.encode(sentences)
return {"embeddings": embeddings.tolist()} # Convert to list for JSON serialization
|