Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a host-side ML API flask app, initially to expose GPU-bound embed…
…dings generation; juggle dev-like things around a bit
- Loading branch information
Showing
15 changed files
with
478 additions
and
579 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
docker_services: docker compose -f compose-dev.yaml up | ||
mlapi_service: ./scripts/start-mlapi-dev.sh | ||
host_notebook: ./scripts/start-host-notebook.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import json | ||
|
||
from flask import Flask, request, jsonify | ||
from flask_sqlalchemy import SQLAlchemy | ||
from flask_migrate import Migrate | ||
|
||
from sentence_transformers import SentenceTransformer | ||
|
||
from .config import config | ||
from .log import logger | ||
from .models import db | ||
|
||
|
||
app = Flask(__name__) | ||
embedding_model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2') | ||
|
||
|
||
@app.route('/') | ||
def root(): | ||
return 'Hello' | ||
|
||
|
||
@app.route('/embeddings', methods=['POST']) | ||
def embedding(): | ||
data = request.get_json() | ||
chunks = data['inputs'] | ||
logger.info("Received embeddings request with %d chunks", len(chunks)) | ||
embeddings = embedding_model.encode(chunks) | ||
return jsonify(embeddings.tolist()) | ||
|
Oops, something went wrong.