robinroy03's picture
db index modified
58b27bf
raw
history blame
647 Bytes
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()