ver: 1.1.21:

- Lista dei Cataloghi
- Gestione Cataloghi in base alla configurazione
This commit is contained in:
Surya Paolo
2025-02-10 22:48:53 +01:00
parent 4da257e43a
commit 3d0e307e42
85 changed files with 1419 additions and 547 deletions

View File

@@ -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,
}
}
})