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: , 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()