Spaces:
Sleeping
Sleeping
File size: 647 Bytes
b09edd3 58b27bf b09edd3 cdb02ce b09edd3 cdb02ce b09edd3 cdb02ce b09edd3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
from flask import Flask
from flask import request
from pinecone import Pinecone, ServerlessSpec
import os
PINECONE_DB_API = os.environ.get('PINECONE_DB_API')
pc = Pinecone(api_key=PINECONE_DB_API)
index = pc.Index('fury-py') # NOTE: FOR NOW
app = Flask(__name__)
@app.route("/query", methods=['POST'])
def query():
"""
{
embeddings: <embeddings_list>,
knn: 3
}
"""
data = request.get_json()
embeddings = data['embeddings']
top_k = data['knn']
matches = index.query(
vector = embeddings,
top_k = top_k,
include_metadata = True
)
return matches.to_dict()
|