File size: 611 Bytes
fd39c21 05411e6 fd39c21 62fb42a 05411e6 fd39c21 |
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 |
from flask import Flask
from flask import request
from sentence_transformers import SentenceTransformer
import os
app = Flask(__name__)
model = SentenceTransformer('embedding_model', trust_remote_code=True)
os.environ["TRANSFORMERS_CACHE"] = "/.cache"
@app.route("/embedding", methods=['POST'])
def embedding():
"""
{
text: <text>
}
"""
message = request.get_json()
message = model.encode(message)
return model.encode(message['text'])
# curl -v -X POST 'http://127.0.0.1:8000/completion' --header 'Content-Type: application/json' --data '{"text": "what is an apple?"}' |