diff --git a/docker/app.py b/docker/app.py
index 7c0db45f..2806530a 100644
--- a/docker/app.py
+++ b/docker/app.py
@@ -2,9 +2,10 @@
# -*- coding: utf-8 -*-
import os
import socket
+
+import numpy as np
from flask import Flask, jsonify, request
from laser_encoders import initialize_encoder, initialize_tokenizer
-import numpy as np
app = Flask(__name__)
@@ -12,17 +13,19 @@
@app.route("/")
def root():
print("/")
- html = "
Hello {name}!
" \
- "Hostname: {hostname}
"
+ html = "Hello {name}!
" "Hostname: {hostname}
"
return html.format(name=os.getenv("LASER", "world"), hostname=socket.gethostname())
+
@app.route("/vectorize", methods=["GET"])
def vectorize():
- content = request.args.get('q')
- lang = request.args.get('lang', 'en') # Default to English if 'lang' is not provided
+ content = request.args.get("q")
+ lang = request.args.get(
+ "lang", "en"
+ ) # Default to English if 'lang' is not provided
if content is None:
- return jsonify({'error': 'Missing input content'})
+ return jsonify({"error": "Missing input content"})
encoder = initialize_encoder(lang=lang)
tokenizer = initialize_tokenizer(lang=lang)
@@ -34,9 +37,9 @@ def vectorize():
embeddings = encoder.encode_sentences([tokenized_sentence])
embeddings_list = embeddings.tolist()
- body = {'content': content, 'embedding': embeddings_list}
+ body = {"content": content, "embedding": embeddings_list}
return jsonify(body)
-if __name__ == "__main__":
- app.run(debug=True, port=80, host='0.0.0.0')
+if __name__ == "__main__":
+ app.run(debug=True, port=80, host="0.0.0.0")
diff --git a/docker/encode.py b/docker/encode.py
index 4669d949..f5d49f0a 100644
--- a/docker/encode.py
+++ b/docker/encode.py
@@ -6,4 +6,4 @@
encoder = initialize_encoder(lang="yor")
embeddings = encoder.encode_sentences([tokenized_sentence])
-print("Embeddings Shape", embeddings.shape)
\ No newline at end of file
+print("Embeddings Shape", embeddings.shape)