ver: 1.1.21:
- Lista dei Cataloghi - Gestione Cataloghi in base alla configurazione
This commit is contained in:
@@ -59,24 +59,25 @@ export default defineComponent({
|
||||
const tokenList = [
|
||||
{ label: '50 Token', value: 50 },
|
||||
{ label: '100 Token', value: 100 },
|
||||
{ label: '200 Token', value: 200 },
|
||||
{ label: '500 Token', value: 500 },
|
||||
{ label: '1000 Token', value: 1000 },
|
||||
{ label: '2500 Token', value: 2500 },
|
||||
{ label: '4000 Token', value: 4000 },
|
||||
{ label: '5000 Token', value: 5000 },
|
||||
{ label: '10000 Token', value: 10000 },
|
||||
{ label: '200 Token', value: 200 },
|
||||
{ label: '500 Token', value: 500 },
|
||||
{ label: '1000 Token', value: 1000 },
|
||||
{ label: '2500 Token', value: 2500 },
|
||||
{ label: '4000 Token', value: 4000 },
|
||||
{ label: '5000 Token', value: 5000 },
|
||||
{ label: '10000 Token', value: 10000 },
|
||||
]
|
||||
|
||||
const model = ref('deepseek-chat')
|
||||
const max_tokens = ref(100)
|
||||
const max_tokens = ref(50)
|
||||
const outputType = ref('')
|
||||
const temp = ref(0.3)
|
||||
const temperatura = ref(0.3)
|
||||
const stream = ref(false)
|
||||
const contestsystem = ref('')
|
||||
|
||||
const inputPrompt = ref('');
|
||||
const result = ref('');
|
||||
const outputvisibile = ref('');
|
||||
const isLoading = ref(false);
|
||||
const errorMessage = ref('');
|
||||
const finish_reason = ref('');
|
||||
@@ -95,56 +96,138 @@ export default defineComponent({
|
||||
|
||||
querylist.value = globalStore.getQueryAI()
|
||||
|
||||
outputType.value = outputTypeList[0].value
|
||||
model.value = tools.getCookie('AI_MOD', 'deepseek-chat')
|
||||
max_tokens.value = tools.getCookie('AI_MT', 50, true)
|
||||
withexplain.value = tools.getCookie('AI_WS', '0') === '1'
|
||||
outputType.value = tools.getCookie('AI_OT', outputTypeList[0].value)
|
||||
temperatura.value = tools.convstrToNum(tools.getCookie('AI_TEM', '0.3'))
|
||||
stream.value = tools.getCookie('AI_ST', '0') === '1'
|
||||
contestsystem.value = tools.getCookie('AI_CON', '')
|
||||
inputPrompt.value = tools.getCookie('AI_PRO', '')
|
||||
|
||||
}
|
||||
|
||||
function getInput() {
|
||||
return "Prompt:\n" + inputPrompt.value + '\n\nRisposta:\n'
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
isLoading.value = true;
|
||||
errorMessage.value = '';
|
||||
if (outputvisibile.value) {
|
||||
outputvisibile.value += '\n\n'
|
||||
}
|
||||
outputvisibile.value += getInput();
|
||||
result.value = '';
|
||||
finish_reason.value = '';
|
||||
|
||||
|
||||
tools.setCookie('AI_MOD', model.value)
|
||||
tools.setCookie('AI_MT', max_tokens.value.toString())
|
||||
tools.setCookie('AI_OT', outputType.value)
|
||||
tools.setCookie('AI_TEM', temperatura.value.toString())
|
||||
tools.setCookie('AI_ST', stream.value ? '1' : '0')
|
||||
tools.setCookie('AI_WE', withexplain.value ? '1' : '0')
|
||||
tools.setCookie('AI_CON', contestsystem.value)
|
||||
tools.setCookie('AI_PRO', inputPrompt.value)
|
||||
|
||||
options.value = {
|
||||
model: model.value,
|
||||
max_tokens: max_tokens.value,
|
||||
temp: temp.value,
|
||||
temp: temperatura.value,
|
||||
stream: stream.value,
|
||||
withexplain: withexplain.value,
|
||||
}
|
||||
outputType: outputType.value,
|
||||
};
|
||||
|
||||
try {
|
||||
if (options.value.stream) {
|
||||
// Modalità streaming
|
||||
const response = await globalStore.getQueryDS(inputPrompt.value, options.value);
|
||||
|
||||
const resdata = await globalStore.getQueryDS(inputPrompt.value, options.value)
|
||||
console.log('uscita da getQueryDS')
|
||||
|
||||
if (resdata.code === serv_constants.RIS_CODE_OK) {
|
||||
if (resdata.choice) {
|
||||
finish_reason.value = resdata.choice.finish_reason || ''
|
||||
isLoading.value = false;
|
||||
|
||||
// Leggi il flusso di dati
|
||||
const reader = response.data.getReader();
|
||||
const decoder = new TextDecoder('utf-8');
|
||||
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
|
||||
// Decodifica il chunk e gestisci i dati
|
||||
const chunk = decoder.decode(value);
|
||||
console.log('Received chunk:', chunk); // Log del chunk ricevuto
|
||||
|
||||
const lines = chunk.split('\n\n').filter((line) => line.trim() !== '');
|
||||
|
||||
for (const line of lines) {
|
||||
if (line.startsWith('data: ')) {
|
||||
const data = JSON.parse(line.slice(6)); // Rimuovi "data: " e parsifica il JSON
|
||||
if (data.choice && data.choice.delta && data.choice.delta.content) {
|
||||
result.value += data.choice.delta.content || ''
|
||||
outputvisibile.value += data.choice.delta.content || ''
|
||||
}
|
||||
|
||||
/*errorMessage.value = data.error;
|
||||
$q.notify({
|
||||
color: 'negative',
|
||||
icon: 'error',
|
||||
message: 'Errore durante la richiesta',
|
||||
caption: errorMessage.value,
|
||||
});
|
||||
break; // Interrompi il ciclo in caso di errore
|
||||
}*/
|
||||
} else if (line.startsWith('data: [DONE]')) {
|
||||
const data = JSON.parse(line.slice(12)); // Rimuovi "data: " e parsifica il JSON
|
||||
if (data.choice && data.choice.finish_reason) {
|
||||
finish_reason.value = data.choice.finish_reason;
|
||||
}
|
||||
inputPrompt.value = '';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (resdata.choice.message) {
|
||||
result.value = resdata.choice.message.content || ''
|
||||
} else {
|
||||
// Modalità non streaming
|
||||
const resdata = await globalStore.getQueryDS(inputPrompt.value, options.value);
|
||||
|
||||
if (resdata.code === serv_constants.RIS_CODE_OK) {
|
||||
inputPrompt.value = '';
|
||||
if (resdata.choice) {
|
||||
finish_reason.value = resdata.choice.finish_reason || '';
|
||||
}
|
||||
if (resdata.choice.message) {
|
||||
result.value = resdata.choice.message.content || '';
|
||||
outputvisibile.value += result.value
|
||||
}
|
||||
} else if (resdata.code === serv_constants.RIS_CODE_ERR) {
|
||||
errorMessage.value = resdata.error.message || resdata.error;
|
||||
$q.notify({
|
||||
color: 'negative',
|
||||
icon: 'error',
|
||||
message: 'Errore durante la richiesta',
|
||||
caption: errorMessage.value,
|
||||
});
|
||||
}
|
||||
} else if (resdata.code === serv_constants.RIS_CODE_ERR) {
|
||||
errorMessage.value = resdata.error.message || resdata.error;
|
||||
$q.notify({
|
||||
color: 'negative',
|
||||
icon: 'error',
|
||||
message: 'Errore durante la richiesta',
|
||||
caption: errorMessage.value
|
||||
});
|
||||
|
||||
isLoading.value = false;
|
||||
}
|
||||
|
||||
} catch (error: any) {
|
||||
} catch (error) {
|
||||
errorMessage.value = error.response?.data?.error || error.message;
|
||||
$q.notify({
|
||||
color: 'negative',
|
||||
icon: 'error',
|
||||
message: 'Errore durante la richiesta',
|
||||
caption: errorMessage.value
|
||||
caption: errorMessage.value,
|
||||
});
|
||||
}
|
||||
|
||||
isLoading.value = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
const copyToClipboard = () => {
|
||||
@@ -164,7 +247,14 @@ export default defineComponent({
|
||||
icon: 'error',
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function submitPrompt(event: any) {
|
||||
|
||||
if (inputPrompt.value.trim()) { // Controlla che l'input non sia vuoto
|
||||
handleSubmit(); // Inviare la richiesta
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(mount)
|
||||
|
||||
@@ -175,6 +265,7 @@ export default defineComponent({
|
||||
globalStore,
|
||||
inputPrompt,
|
||||
result,
|
||||
outputvisibile,
|
||||
isLoading,
|
||||
errorMessage,
|
||||
handleSubmit,
|
||||
@@ -193,6 +284,8 @@ export default defineComponent({
|
||||
withexplain,
|
||||
outputType,
|
||||
outputTypeList,
|
||||
temperatura,
|
||||
submitPrompt,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<q-page class="q-pa-md">
|
||||
<q-page class="q-mt-sm q-pa-sm">
|
||||
<div class="column text-center">
|
||||
<div class="row justify-center">
|
||||
<q-select
|
||||
@@ -60,10 +60,10 @@
|
||||
<q-select
|
||||
:behavior="$q.platform.is.ios === true ? 'dialog' : 'menu'"
|
||||
outlined
|
||||
v-model="temp"
|
||||
v-model="temperatura"
|
||||
style="min-width: 200px"
|
||||
:options="tempList"
|
||||
:label="t('queryai.temp') + `:`"
|
||||
:label="t('queryai.temperatura') + `:`"
|
||||
emit-value
|
||||
map-options
|
||||
option-value="value"
|
||||
@@ -76,7 +76,7 @@
|
||||
v-model="outputType"
|
||||
style="min-width: 200px"
|
||||
:options="outputTypeList"
|
||||
:label="t('queryai.numtoken') + `:`"
|
||||
:label="t('queryai.outputType') + `:`"
|
||||
emit-value
|
||||
map-options
|
||||
option-value="value"
|
||||
@@ -105,54 +105,35 @@
|
||||
<q-separator></q-separator>
|
||||
</div>
|
||||
|
||||
<div class="q-mt-md q-gutter-y-md">
|
||||
<q-form @submit.prevent="handleSubmit">
|
||||
<q-input
|
||||
v-model="inputPrompt"
|
||||
filled
|
||||
autogrow
|
||||
type="textarea"
|
||||
label="Inserisci la tua richiesta"
|
||||
hint="Scrivi qui il tuo prompt"
|
||||
class="q-mb-md"
|
||||
autofocus
|
||||
<q-card v-if="outputvisibile" class="q-mt-sm">
|
||||
<q-card-section>
|
||||
<q-scroll-area style="height: 300px">
|
||||
<pre class="response-content">{{ outputvisibile }}</pre>
|
||||
</q-scroll-area>
|
||||
<q-btn
|
||||
flat
|
||||
round
|
||||
dense
|
||||
label="Copia la Risposta"
|
||||
icon="content_copy"
|
||||
@click="copyToClipboard"
|
||||
v-tooltip="'Copia negli appunti'"
|
||||
/>
|
||||
<pre class="response-reason">Esito: {{ finish_reason }}</pre>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
||||
<div class="text-center">
|
||||
<q-btn
|
||||
:label="`Invia a ` + modelLabel"
|
||||
type="submit"
|
||||
color="primary"
|
||||
:loading="isLoading"
|
||||
icon="send"
|
||||
/>
|
||||
</div>
|
||||
</q-form>
|
||||
|
||||
MARKDOWN:
|
||||
<q-markdown :content="`L'altezza \( h \) di un triangolo isoscele con base 10 è \( h = \sqrt{l^2 - 25} \), dove \( l \) è la lunghezza dei lati congruenti.`" />
|
||||
|
||||
<q-card v-if="result" class="q-mt-md">
|
||||
<q-card-section>
|
||||
<div class="text-h6 row items-center justify-between">
|
||||
<span>Risposta</span>
|
||||
<q-btn
|
||||
flat
|
||||
round
|
||||
dense
|
||||
icon="content_copy"
|
||||
@click="copyToClipboard"
|
||||
v-tooltip="'Copia negli appunti'"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<q-markdown :content="result" />
|
||||
<q-scroll-area style="height: 300px">
|
||||
<pre class="response-content">{{ result }}</pre>
|
||||
</q-scroll-area>
|
||||
<pre class="response-reason">Esito: {{ finish_reason }}</pre>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
<div class="q-mt-md q-gutter-y-md">
|
||||
<q-input
|
||||
v-model="inputPrompt"
|
||||
filled
|
||||
autogrow
|
||||
type="textarea"
|
||||
label="Inserisci la tua richiesta"
|
||||
class="q-mb-md"
|
||||
autofocus
|
||||
@keydown.enter.prevent="submitPrompt"
|
||||
/>
|
||||
|
||||
<q-banner
|
||||
v-if="errorMessage"
|
||||
@@ -162,6 +143,18 @@ MARKDOWN:
|
||||
{{ errorMessage }}
|
||||
</q-banner>
|
||||
|
||||
<div class="text-center">
|
||||
<q-btn
|
||||
:label="`Invia a ` + modelLabel"
|
||||
type="submit"
|
||||
color="primary"
|
||||
:disable="!inputPrompt"
|
||||
:loading="isLoading"
|
||||
icon="send"
|
||||
@click="handleSubmit"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<q-inner-loading :showing="isLoading">
|
||||
<q-spinner-gears size="50px" color="primary" />
|
||||
<div class="q-mt-sm">Elaborazione richiesta...</div>
|
||||
|
||||
Reference in New Issue
Block a user