Skip to content

Commit

Permalink
29 - more improvements for revision
Browse files Browse the repository at this point in the history
Signed-off-by: marijnvg-tng <[email protected]>
  • Loading branch information
marijnvg-tng committed Nov 22, 2024
1 parent 28cca0f commit 160f92a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 27 deletions.
18 changes: 5 additions & 13 deletions WebUI/src/components/AddLLMDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ function fastGenerate(e: KeyboardEvent) {
modelRequest.value += "\n";
} else {
e.preventDefault();
addModel()
if (modelRequest.value !== "") {
addModel()
}
}
}
}
Expand Down Expand Up @@ -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
}
Expand Down
16 changes: 9 additions & 7 deletions WebUI/src/views/Answer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion service/model_downloader.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 6 additions & 6 deletions service/web_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,24 +195,24 @@ 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(
{
"exists": 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(
Expand Down

0 comments on commit 160f92a

Please sign in to comment.