Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ from fastapi import FastAPI, Request, Query
|
|
2 |
from fastapi.templating import Jinja2Templates
|
3 |
from fastapi import File, UploadFile
|
4 |
from fastapi.responses import FileResponse
|
|
|
5 |
|
6 |
from pydantic import BaseModel
|
7 |
from sentence_transformers import SentenceTransformer
|
@@ -43,7 +44,7 @@ def embed_strings(request: EmbedRequest):
|
|
43 |
def search_string(request: SearchRequest):
|
44 |
embedding = model.encode([request.text])
|
45 |
distances, indices = index.search(np.array(embedding), request.n)
|
46 |
-
found_documents = index.reconstruct_n(indices[0], request.n)
|
47 |
return {
|
48 |
"distances": distances[0].tolist(),
|
49 |
"indices": indices[0].tolist(),
|
|
|
2 |
from fastapi.templating import Jinja2Templates
|
3 |
from fastapi import File, UploadFile
|
4 |
from fastapi.responses import FileResponse
|
5 |
+
from fastapi.responses import Response
|
6 |
|
7 |
from pydantic import BaseModel
|
8 |
from sentence_transformers import SentenceTransformer
|
|
|
44 |
def search_string(request: SearchRequest):
|
45 |
embedding = model.encode([request.text])
|
46 |
distances, indices = index.search(np.array(embedding), request.n)
|
47 |
+
found_documents = index.reconstruct_n(indices[0], int(request.n))
|
48 |
return {
|
49 |
"distances": distances[0].tolist(),
|
50 |
"indices": indices[0].tolist(),
|