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