forked from intel/AI-Playground
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/26 llm download from dropdown backup #3
Merged
mschuettlerTNG
merged 10 commits into
dev
from
Feat/26--LLM_download_from_dropdown_backup
Nov 26, 2024
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d6689e7
26 - Added + button and simple pop-up structure; connection to downlo…
julianbollig 409131a
26 - Implemented functioning download request from the 'addLLMDialog'…
marijnvg-tng e3944b8
26 - Finalizing adding additional user models functionality.
marijnvg-tng 1a83745
26 - Optimized Design
julianbollig d01f15d
26 - added warning if download model is not an LLM
julianbollig 7a86aa0
26 - Code cleanup after revision
marijnvg-tng 138151c
26 - Fixed minor inaccuracies
marijnvg-tng a325a2d
26 - more improvements for revision
marijnvg-tng c617ce0
26 - Adding final changes before merging with dev
julianbollig 2916814
Implement review comments
mschuettlerTNG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,114 @@ | ||
<template> | ||
<div class="dialog-container z-10"> | ||
<div class="dialog-mask absolute left-0 top-0 w-full h-full bg-black/55 flex justify-center items-center"> | ||
<div class="py-10 px-20 w-500px flex flex-col items-center justify-center bg-gray-600 rounded-3xl gap-6 text-white" | ||
florianesser-tng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
:class="{ 'animate-scale-in': animate }"> | ||
<p v-html= "i18nState.REQUEST_LLM_MODEL_NAME"></p> | ||
<textarea class="rounded-xl border border-color-spilter flex-auto w-full h-auto resize-none" rows="1" | ||
:placeholder="languages.COM_LLM_HF_PROMPT" v-model="modelRequest" @keydown="fastGenerate"></textarea> | ||
marijnvg-tng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<p v-show = "addModelError" style="color: #F44336;">{{ addModelErrorMessage }}</p> | ||
florianesser-tng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<div class="flex justify-center items-center gap-9"> | ||
<button @click="closeAdd" class="bg-color-control-bg py-1 px-4 rounded">{{ i18nState.COM_CLOSE }}</button> | ||
<button @click="addModel" class="bg-color-control-bg py-1 px-4 rounded">{{ i18nState.COM_ADD }}</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
<script setup lang="ts"> | ||
import { useGlobalSetup } from '@/assets/js/store/globalSetup'; | ||
import { useI18N } from '@/assets/js/store/i18n'; | ||
import { useModels, userModels } from '@/assets/js/store/models'; | ||
|
||
|
||
const i18nState = useI18N().state; | ||
const globalSetup = useGlobalSetup(); | ||
const models = useModels(); | ||
const modelRequest = ref(""); | ||
const addModelErrorMessage = ref("") | ||
const addModelError = ref(false); | ||
const animate = ref(false); | ||
const emits = defineEmits<{ | ||
(e: "close"): void, | ||
(e: "callCheckModel"): void, | ||
(e: "showWarning", warning : string, func : () => void): void | ||
}>(); | ||
|
||
|
||
function fastGenerate(e: KeyboardEvent) { | ||
if (e.code == "Enter") { | ||
if (e.ctrlKey || e.shiftKey || e.altKey) { | ||
marijnvg-tng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
modelRequest.value += "\n"; | ||
} else { | ||
e.preventDefault(); | ||
if (modelRequest.value !== "") { | ||
addModel() | ||
} | ||
} | ||
} | ||
} | ||
|
||
function onShow() { | ||
animate.value = true; | ||
} | ||
|
||
async function addModel() { | ||
const previousModel = globalSetup.modelSettings.llm_model | ||
const is_in_models = models.models.some((model) => model.name === modelRequest.value) | ||
florianesser-tng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (!is_in_models) { | ||
const url_exists = await urlExists(modelRequest.value); | ||
if (url_exists) { | ||
addModelError.value = false | ||
const is_llm = await isLLM(modelRequest.value); | ||
if (!is_llm) { | ||
emits("showWarning", i18nState.WARNING_MODEL_TYPE_WRONG, async() => { | ||
await registerModel(); | ||
emits("callCheckModel"); | ||
closeAdd(); | ||
}); | ||
} else { | ||
await registerModel() | ||
emits("callCheckModel"); | ||
closeAdd(); | ||
} | ||
} else { | ||
globalSetup.modelSettings.llm_model = previousModel | ||
addModelErrorMessage.value = i18nState.ERROR_REPO_NOT_EXISTS | ||
addModelError.value = true; | ||
} | ||
} else { | ||
globalSetup.modelSettings.llm_model = previousModel | ||
addModelErrorMessage.value = i18nState.ERROR_ALREADY_IN_MODELS | ||
addModelError.value = true; | ||
} | ||
} | ||
|
||
async function registerModel() { | ||
userModels.push({name: modelRequest.value, type: 'llm', downloaded: false}) | ||
await models.refreshModels() | ||
globalSetup.modelSettings.llm_model = modelRequest.value; | ||
} | ||
|
||
async function urlExists(repo_id: string) { | ||
const response = await fetch(`${globalSetup.apiHost}/api/checkHFRepoExists?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?repo_id=${repo_id}`) | ||
const data = await response.json() | ||
return data.isllm | ||
} | ||
|
||
function closeAdd() { | ||
addModelErrorMessage.value = ""; | ||
addModelError.value = false; | ||
julianbollig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
modelRequest.value = ""; | ||
emits("close"); | ||
} | ||
|
||
defineExpose({ onShow }); | ||
|
||
</script> |
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,41 @@ | ||
<template> | ||
<div class="dialog-container z-10"> | ||
<div class="dialog-mask absolute left-0 top-0 w-full h-full bg-black/55 flex justify-center items-center"> | ||
<div class="py-10 px-20 w-500px flex flex-col items-center justify-center bg-gray-600 rounded-3xl gap-6 text-white" | ||
:class="{ 'animate-scale-in': animate }"> | ||
<p v-html= "warningMessage"></p> | ||
<div class="flex justify-center items-center gap-9"> | ||
<button @click="cancelConfirm" class="bg-color-control-bg py-1 px-4 rounded">{{i18nState.COM_CANCEL}}</button> | ||
<button @click="confirmAdd" class="bg-color-control-bg py-1 px-4 rounded">{{i18nState.COM_CONFIRM}}</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
<script setup lang="ts"> | ||
import { useI18N } from '@/assets/js/store/i18n.ts'; | ||
const i18nState = useI18N().state; | ||
const confirmFunction = ref(() => {}) | ||
const warningMessage = ref("") | ||
const animate = ref(false); | ||
const emits = defineEmits<{ | ||
(e: "close"): void | ||
}>(); | ||
|
||
|
||
async function confirmAdd() { | ||
confirmFunction.value() | ||
emits("close"); | ||
} | ||
|
||
function cancelConfirm() { | ||
emits("close"); | ||
} | ||
|
||
function onShow(){ | ||
animate.value = true | ||
} | ||
|
||
defineExpose({warningMessage, confirmFunction, onShow }); | ||
|
||
</script> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not yet convinced, that the llmDialog and the warning dialog should be on this level. My feeling is: keep app.vue as slim as possible, otherwise we will not be able to mentally control it in the long run. We already have some "noise" of events, that simply flip booleans to display some popup/dialogs.
my gut feeling: introduce the add$ModelType as a component on its own , where type is probably (on the long run) corresponding to the view $answer/create/enhance -> llm/stablediff/??? . Probably, in considering the correct hierarchies, one arrives at a cleaner communication between components overall, especially when it comes to delegating events to the download component.
I would also be willing with this design for now and get feedback of intel. But imo we need to be very careful in not letting this degrade.
I am however happy to hear, if you spent thoughts on this