From 3e80e9c0163062f59d83351a8d775bf40ca18447 Mon Sep 17 00:00:00 2001 From: jan-kordas Date: Tue, 14 Jan 2025 15:49:37 +0100 Subject: [PATCH] fixed bug caused by empty user input, added full names of models and Alibaba recommended --- src/app/main.py | 14 ++++++++++---- src/app/templates/index.html | 18 ++++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/app/main.py b/src/app/main.py index 6b26e4d..2f726ba 100644 --- a/src/app/main.py +++ b/src/app/main.py @@ -33,11 +33,17 @@ alibaba_embeddings=load_embeddings(alibaba_embeddings_path) @app.route("/", methods=["GET", "POST"]) def index(): if request.method == "POST": - user_input = request.form["description"] - model_type = request.form["model_type"] - performance_choice = request.form["preference_choice"] - similarity_metric = request.form["similarity_metric"] + user_input = request.form.get("description", "").strip() + if not user_input: + return render_template( + "index.html", + error="Please provide a description to get movie recommendations." + ) + model_type = request.form.get("model_type", "") + performance_choice = request.form.get("preference_choice", "") + similarity_metric = request.form.get("similarity_metric", "") + if model_type == "bert": model = bert_model tokenizer = bert_tokenizer diff --git a/src/app/templates/index.html b/src/app/templates/index.html index 5ff440f..24745d7 100644 --- a/src/app/templates/index.html +++ b/src/app/templates/index.html @@ -42,10 +42,16 @@

Filmosfera

+ {% if error %} + + {% endif %} +
- +
@@ -65,10 +71,10 @@
@@ -94,4 +100,4 @@
- \ No newline at end of file +