From 160f92ae3d712660e54046717bc6549a0141a9e5 Mon Sep 17 00:00:00 2001 From: marijnvg-tng Date: Fri, 22 Nov 2024 13:57:35 +0100 Subject: [PATCH] 29 - more improvements for revision Signed-off-by: marijnvg-tng --- WebUI/src/components/AddLLMDialog.vue | 18 +++++------------- WebUI/src/views/Answer.vue | 16 +++++++++------- service/model_downloader.py | 2 +- service/web_api.py | 12 ++++++------ 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/WebUI/src/components/AddLLMDialog.vue b/WebUI/src/components/AddLLMDialog.vue index 8a1d6638..b2238771 100644 --- a/WebUI/src/components/AddLLMDialog.vue +++ b/WebUI/src/components/AddLLMDialog.vue @@ -41,7 +41,9 @@ function fastGenerate(e: KeyboardEvent) { modelRequest.value += "\n"; } else { e.preventDefault(); - addModel() + if (modelRequest.value !== "") { + addModel() + } } } } @@ -85,23 +87,13 @@ async function performDownload() { } async function urlExists(repo_id: string) { - const response = await fetch(`${globalSetup.apiHost}/api/checkURLExists`, { - method: "POST", - body: JSON.stringify(repo_id), - headers: { - "Content-Type": "application/json" - }}) + const response = await fetch(`${globalSetup.apiHost}/api/checkURLExists?repo_id=${repo_id}`) const data = await response.json() return data.exists; } async function isLLM(repo_id: string) { - const response = await fetch(`${globalSetup.apiHost}/api/isLLM`, { - method: "POST", - body: JSON.stringify(repo_id), - headers: { - "Content-Type": "application/json" - }}) + const response = await fetch(`${globalSetup.apiHost}/api/isLLM?repo_id=${repo_id}`) const data = await response.json() return data.isllm } diff --git a/WebUI/src/views/Answer.vue b/WebUI/src/views/Answer.vue index 603ff59c..56c60963 100644 --- a/WebUI/src/views/Answer.vue +++ b/WebUI/src/views/Answer.vue @@ -388,14 +388,16 @@ async function simulatedInput() { } function fastGenerate(e: KeyboardEvent) { - if (e.code == "Enter") { - if (e.ctrlKey || e.shiftKey || e.altKey) { - question.value += "\n"; - } else { - e.preventDefault(); - newPromptGenerate(); - } + if (e.code == "Enter") { + if (e.ctrlKey || e.shiftKey || e.altKey) { + question.value += "\n"; + } else { + e.preventDefault(); + if (question.value !== "") { + newPromptGenerate() + } } + } } async function newPromptGenerate() { diff --git a/service/model_downloader.py b/service/model_downloader.py index 16d0ffc9..a9df3b9d 100644 --- a/service/model_downloader.py +++ b/service/model_downloader.py @@ -1,5 +1,5 @@ from huggingface_hub import HfFileSystem, hf_hub_url, model_info -from huggingface_hub.utils._errors import RepositoryNotFoundError +from huggingface_hub.utils import RepositoryNotFoundError from typing import Any, Callable, Dict, List from os import path, makedirs, rename import requests diff --git a/service/web_api.py b/service/web_api.py index b5f63755..d8ff507e 100644 --- a/service/web_api.py +++ b/service/web_api.py @@ -195,11 +195,11 @@ def check_model_exist(): return jsonify({"code": 0, "message": "success", "exists": result_list}) -@app.route("/api/checkURLExists", methods=["POST"]) +@app.route("/api/checkURLExists", methods=["GET"]) def check_url_exists(): - address = request.get_json() + repo_id = request.args.get('repo_id') downloader = HFPlaygroundDownloader() - exists = downloader.hf_url_exists(address) + exists = downloader.hf_url_exists(repo_id) return jsonify( { @@ -207,12 +207,12 @@ def check_url_exists(): } ) -@app.route("/api/isLLM", methods=["POST"]) +@app.route("/api/isLLM", methods=["GET"]) def is_llm(): - address = request.get_json() + repo_id = request.args.get('repo_id') downloader = HFPlaygroundDownloader() try: - model_type_hf = downloader.probe_type(address) + model_type_hf = downloader.probe_type(repo_id) except Exception: model_type_hf = "undefined" return jsonify(