robinroy03's picture
fixed bugs, first production version -- 0.0
3ddc84f
raw
history blame contribute delete
634 Bytes
from flask import Flask
from flask import request
from sentence_transformers import SentenceTransformer
import os
app = Flask(__name__)
os.environ["TRANSFORMERS_CACHE"] = "/.cache"
model = SentenceTransformer('Alibaba-NLP/gte-large-en-v1.5', trust_remote_code=True)
@app.route("/embedding", methods=['POST'])
def embedding():
"""
{
text: <text>
}
"""
message = request.get_json()
message = model.encode(message['text'])
return {"output": message.tolist()}
# curl -v -X POST 'http://127.0.0.1:8000/embedding' --header 'Content-Type: application/json' --data '{"text": "what is an apple?"}'