diff --git a/.env.development b/.env.development index 1121d220..d1a06f17 100755 --- a/.env.development +++ b/.env.development @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="18" DIRECTORY_LOCAL="newfreeplanet" diff --git a/.env.example.production b/.env.example.production index f88ad438..ba9401b2 100755 --- a/.env.example.production +++ b/.env.example.production @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="13" DIRECTORY_LOCAL=newfreeplanet diff --git a/.env.prod.gruppomacro b/.env.prod.gruppomacro index 04fb5b58..3dfb7e38 100644 --- a/.env.prod.gruppomacro +++ b/.env.prod.gruppomacro @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="18" DIRECTORY_LOCAL=newfreeplanet diff --git a/.env.prod.pcb b/.env.prod.pcb index 2464f4a2..3bc2e151 100644 --- a/.env.prod.pcb +++ b/.env.prod.pcb @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="17" DIRECTORY_LOCAL="newfreeplanet" diff --git a/.env.prod.riso b/.env.prod.riso index 314ca544..b1903c2c 100644 --- a/.env.prod.riso +++ b/.env.prod.riso @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="13" DIRECTORY_LOCAL=newfreeplanet diff --git a/.env.production b/.env.production index b44a2d3d..4660546a 100644 --- a/.env.production +++ b/.env.production @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="13" DIRECTORY_LOCAL=newfreeplanet diff --git a/.env.test.abitaregliiblei.it b/.env.test.abitaregliiblei.it index 60d36cba..fb4efc52 100755 --- a/.env.test.abitaregliiblei.it +++ b/.env.test.abitaregliiblei.it @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="19" DIRECTORY_LOCAL=newfreeplanet diff --git a/.env.test.gruppomacro b/.env.test.gruppomacro index e829846c..9a82e563 100755 --- a/.env.test.gruppomacro +++ b/.env.test.gruppomacro @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="18" DIRECTORY_LOCAL=newfreeplanet diff --git a/.env.test.pcb b/.env.test.pcb index 1e9d72c9..22571328 100755 --- a/.env.test.pcb +++ b/.env.test.pcb @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="17" DIRECTORY_LOCAL="newfreeplanet" diff --git a/.env.test.risosrv b/.env.test.risosrv index ca644178..fd49801e 100755 --- a/.env.test.risosrv +++ b/.env.test.risosrv @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="13" DIRECTORY_LOCAL=newfreeplanet diff --git a/.env.test2 b/.env.test2 index ac6cb999..410dc349 100755 --- a/.env.test2 +++ b/.env.test2 @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="13" DIRECTORY_LOCAL=newfreeplanet diff --git a/.env.test_riso.pcb b/.env.test_riso.pcb index d5db3c32..a9050740 100755 --- a/.env.test_riso.pcb +++ b/.env.test_riso.pcb @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="13" DIRECTORY_LOCAL=newfreeplanet diff --git a/_ALL_SITES/abitaregliiblei.it/.env.development b/_ALL_SITES/abitaregliiblei.it/.env.development index 236b32d2..605f1705 100755 --- a/_ALL_SITES/abitaregliiblei.it/.env.development +++ b/_ALL_SITES/abitaregliiblei.it/.env.development @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="19" DIRECTORY_LOCAL="newfreeplanet" diff --git a/_ALL_SITES/abitaregliiblei.it/.env.production b/_ALL_SITES/abitaregliiblei.it/.env.production index 9dc24d1a..a94af3ba 100644 --- a/_ALL_SITES/abitaregliiblei.it/.env.production +++ b/_ALL_SITES/abitaregliiblei.it/.env.production @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="19" DIRECTORY_LOCAL=newfreeplanet diff --git a/_ALL_SITES/abitaregliiblei.it/package.json b/_ALL_SITES/abitaregliiblei.it/package.json index 9f31ae9c..b430e383 100755 --- a/_ALL_SITES/abitaregliiblei.it/package.json +++ b/_ALL_SITES/abitaregliiblei.it/package.json @@ -1,6 +1,6 @@ { "name": "abitaregliiblei", - "version": "1.1.20", + "version": "1.1.21", "description": "Abitare Gli Iblei", "productName": "AbitareGliIblei", "author": "Surya", diff --git a/_ALL_SITES/comunitanuovomondo.app/.env.development b/_ALL_SITES/comunitanuovomondo.app/.env.development index 5448937a..33642acc 100755 --- a/_ALL_SITES/comunitanuovomondo.app/.env.development +++ b/_ALL_SITES/comunitanuovomondo.app/.env.development @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="13" DIRECTORY_LOCAL="newfreeplanet" diff --git a/_ALL_SITES/comunitanuovomondo.app/.env.production b/_ALL_SITES/comunitanuovomondo.app/.env.production index b44a2d3d..4660546a 100644 --- a/_ALL_SITES/comunitanuovomondo.app/.env.production +++ b/_ALL_SITES/comunitanuovomondo.app/.env.production @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="13" DIRECTORY_LOCAL=newfreeplanet diff --git a/_ALL_SITES/comunitanuovomondo.app/.env.test b/_ALL_SITES/comunitanuovomondo.app/.env.test index ba5d5d4a..e020bb5b 100755 --- a/_ALL_SITES/comunitanuovomondo.app/.env.test +++ b/_ALL_SITES/comunitanuovomondo.app/.env.test @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="16" DIRECTORY_LOCAL=newfreeplanet diff --git a/_ALL_SITES/comunitanuovomondo.app/package.json b/_ALL_SITES/comunitanuovomondo.app/package.json index 0916e8c8..ceed5e58 100755 --- a/_ALL_SITES/comunitanuovomondo.app/package.json +++ b/_ALL_SITES/comunitanuovomondo.app/package.json @@ -1,6 +1,6 @@ { "name": "riso", - "version": "1.1.20", + "version": "1.1.21", "description": "Siamo la Rete Italiana di Scambio Orizzontale, abbiamo creato questa piattaforma per metterla al servizio di chi vuole riscoprire il valore della condivisione e della cooperazione. Valori semplici e profondi che ci aiutano a ritrovare il Senso della Vita, perduto in questa società consumista, e riporti quei Sani Pricìpi Naturali ed Umani di Fratellanza che intere popolazioni antiche conoscevano bene.", "productName": "Riso", "author": "Surya", diff --git a/_ALL_SITES/fioredellavita.riso.app/.env.development b/_ALL_SITES/fioredellavita.riso.app/.env.development index 8ef26ba0..82b6ef13 100755 --- a/_ALL_SITES/fioredellavita.riso.app/.env.development +++ b/_ALL_SITES/fioredellavita.riso.app/.env.development @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="15" DIRECTORY_LOCAL="newfreeplanet" diff --git a/_ALL_SITES/fioredellavita.riso.app/.env.production b/_ALL_SITES/fioredellavita.riso.app/.env.production index 8e531f55..1869a7a2 100644 --- a/_ALL_SITES/fioredellavita.riso.app/.env.production +++ b/_ALL_SITES/fioredellavita.riso.app/.env.production @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="15" DIRECTORY_LOCAL=newfreeplanet diff --git a/_ALL_SITES/fioredellavita.riso.app/.env.test b/_ALL_SITES/fioredellavita.riso.app/.env.test index 3c94dba9..80ba0219 100755 --- a/_ALL_SITES/fioredellavita.riso.app/.env.test +++ b/_ALL_SITES/fioredellavita.riso.app/.env.test @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="15" DIRECTORY_LOCAL=newfreeplanet diff --git a/_ALL_SITES/fioredellavita.riso.app/package.json b/_ALL_SITES/fioredellavita.riso.app/package.json index 752b9a1d..0c4dd620 100755 --- a/_ALL_SITES/fioredellavita.riso.app/package.json +++ b/_ALL_SITES/fioredellavita.riso.app/package.json @@ -1,6 +1,6 @@ { "name": "fioredellavita", - "version": "1.1.20", + "version": "1.1.21", "description": "Fiore Della Vita", "productName": "Fiore Della Vita", "author": "Surya", diff --git a/_ALL_SITES/gruppomacro.app/.env.development b/_ALL_SITES/gruppomacro.app/.env.development index 1121d220..d1a06f17 100755 --- a/_ALL_SITES/gruppomacro.app/.env.development +++ b/_ALL_SITES/gruppomacro.app/.env.development @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="18" DIRECTORY_LOCAL="newfreeplanet" diff --git a/_ALL_SITES/gruppomacro.app/.env.test b/_ALL_SITES/gruppomacro.app/.env.test index e829846c..9a82e563 100755 --- a/_ALL_SITES/gruppomacro.app/.env.test +++ b/_ALL_SITES/gruppomacro.app/.env.test @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="18" DIRECTORY_LOCAL=newfreeplanet diff --git a/_ALL_SITES/gruppomacro.app/package.json b/_ALL_SITES/gruppomacro.app/package.json index 184fe0dd..feb7adb8 100755 --- a/_ALL_SITES/gruppomacro.app/package.json +++ b/_ALL_SITES/gruppomacro.app/package.json @@ -1,6 +1,6 @@ { "name": "gruppomacro", - "version": "1.1.20", + "version": "1.1.21", "description": "GruppoMacro", "productName": "Gruppo Macro", "author": "Surya", diff --git a/_ALL_SITES/piuchebuono.app/.env.development b/_ALL_SITES/piuchebuono.app/.env.development index 52dd0421..ec54eae6 100755 --- a/_ALL_SITES/piuchebuono.app/.env.development +++ b/_ALL_SITES/piuchebuono.app/.env.development @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="17" DIRECTORY_LOCAL="newfreeplanet" diff --git a/_ALL_SITES/piuchebuono.app/.env.test b/_ALL_SITES/piuchebuono.app/.env.test index 1e9d72c9..22571328 100755 --- a/_ALL_SITES/piuchebuono.app/.env.test +++ b/_ALL_SITES/piuchebuono.app/.env.test @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="17" DIRECTORY_LOCAL="newfreeplanet" diff --git a/_ALL_SITES/piuchebuono.app/package.json b/_ALL_SITES/piuchebuono.app/package.json index d78cec97..bf7b6bbf 100755 --- a/_ALL_SITES/piuchebuono.app/package.json +++ b/_ALL_SITES/piuchebuono.app/package.json @@ -1,6 +1,6 @@ { "name": "piuchebuono", - "version": "1.1.20", + "version": "1.1.21", "description": "PiuCheBuono", "productName": "PiuCheBuono", "author": "Surya", diff --git a/_ALL_SITES/riso.app/.env.development b/_ALL_SITES/riso.app/.env.development index 5448937a..33642acc 100755 --- a/_ALL_SITES/riso.app/.env.development +++ b/_ALL_SITES/riso.app/.env.development @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="13" DIRECTORY_LOCAL="newfreeplanet" diff --git a/_ALL_SITES/riso.app/.env.production b/_ALL_SITES/riso.app/.env.production index b44a2d3d..4660546a 100644 --- a/_ALL_SITES/riso.app/.env.production +++ b/_ALL_SITES/riso.app/.env.production @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="13" DIRECTORY_LOCAL=newfreeplanet diff --git a/_ALL_SITES/riso.app/.env.test b/_ALL_SITES/riso.app/.env.test index ba5d5d4a..e020bb5b 100755 --- a/_ALL_SITES/riso.app/.env.test +++ b/_ALL_SITES/riso.app/.env.test @@ -1,4 +1,4 @@ -APP_VERSION="1.1.20" +APP_VERSION="1.1.21" SERVICE_WORKER_FILE="service-worker.js" APP_ID="16" DIRECTORY_LOCAL=newfreeplanet diff --git a/_ALL_SITES/riso.app/package.json b/_ALL_SITES/riso.app/package.json index 0916e8c8..ceed5e58 100755 --- a/_ALL_SITES/riso.app/package.json +++ b/_ALL_SITES/riso.app/package.json @@ -1,6 +1,6 @@ { "name": "riso", - "version": "1.1.20", + "version": "1.1.21", "description": "Siamo la Rete Italiana di Scambio Orizzontale, abbiamo creato questa piattaforma per metterla al servizio di chi vuole riscoprire il valore della condivisione e della cooperazione. Valori semplici e profondi che ci aiutano a ritrovare il Senso della Vita, perduto in questa società consumista, e riporti quei Sani Pricìpi Naturali ed Umani di Fratellanza che intere popolazioni antiche conoscevano bene.", "productName": "Riso", "author": "Surya", diff --git a/config/webpack.config.base.js b/config/webpack.config.base.js index 77c2885a..c4c4e3a2 100755 --- a/config/webpack.config.base.js +++ b/config/webpack.config.base.js @@ -8,6 +8,7 @@ const postcssImport = require('postcss-import'); const helpers = require('./helpers'); const baseConfig = { + mode: 'production', entry: { bundle: path.resolve(__dirname, '/src/main.ts'), }, diff --git a/package.json b/package.json index 41da76b6..862d9ab0 100755 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "riso", - "version": "1.1.20", - "description": "Siamo la Rete Italiana di Scambio Orizzontale, abbiamo creato questa piattaforma per metterla al servizio di chi vuole riscoprire il valore della condivisione e della cooperazione. Valori semplici e profondi che ci aiutano a ritrovare il Senso della Vita, perduto in questa società consumista, e riporti quei Sani Pricìpi Naturali ed Umani di Fratellanza che intere popolazioni antiche conoscevano bene.", - "productName": "Riso", + "name": "gruppomacro", + "version": "1.1.21", + "description": "Gruppo Macro", + "productName": "Gruppo Macro", "author": "Surya", "private": true, "keywords": [], @@ -35,7 +35,7 @@ "@types/leaflet": "^1.9.16", "@vue/compat": "^3.5.13", "@vue/compiler-sfc": "^3.5.13", - "@vue/eslint-config-standard": "^8.0.1", + "@vue/eslint-config-standard": "^9.0.0", "@vuelidate/core": "^2.0.3", "@vuelidate/validators": "^2.0.4", "acorn": "^8.14.0", @@ -70,6 +70,7 @@ "quasar": "^2.17.7", "quasar-extras": "^2.0.9", "register-service-worker": "^1.7.2", + "rxjs": "^7.8.1", "typescript-eslint": "^8.23.0", "vee-validate": "^4.15.0", "vue": "^3.5.13", @@ -114,7 +115,7 @@ "babel-loader": "^9.2.1", "copy-webpack-plugin": "^12.0.2", "eslint": "^9.19.0", - "eslint-config-prettier": "9.1.0", + "eslint-config-prettier": "10.0.1", "eslint-plugin-import": "^2.31.0", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^7.2.1", @@ -137,7 +138,7 @@ "strip-ansi": "=7.1.0", "ts-jest": "^29.2.5", "ts-loader": "^9.5.2", - "typescript": "5.6.2", + "typescript": "5.7.3", "vue-cli-plugin-element-ui": "^1.1.4", "vueify": "^9.4.1", "webpack": "^5.97.1", @@ -161,7 +162,7 @@ "not dead" ], "engines": { - "node": ">= 18.18.0", + "node": ">= 22.13.1", "npm": ">= 6.14.8", "yarn": ">= 1.21.1" } diff --git a/src-pwa/custom-service-worker.js b/src-pwa/custom-service-worker.js index 7342b37e..21d9af4c 100755 --- a/src-pwa/custom-service-worker.js +++ b/src-pwa/custom-service-worker.js @@ -34,7 +34,7 @@ self.addEventListener('activate', (event) => { }); -const APP_VERSION = "1.1.20"; +const APP_VERSION = "1.1.21"; console.log(' [ VER-' + APP_VERSION + ' ] _---------________------ PAO: this is my custom service worker'); @@ -295,13 +295,13 @@ if (workbox) { return response; } catch (error) { - console.error('[Service Worker] Fetch error:', error); + console.error('[Service Worker] Fetch error:', error, request); // Personalizza la risposta di errore in base al tipo di richiesta if (request.headers.get('Accept')?.includes('application/json')) { return new Response(JSON.stringify({ error: 'Network error', - message: 'Service unavailable' + message: 'Servizio non disponibile, riprovare !' }), { status: 503, headers: { diff --git a/src/common/shared_vuejs.ts b/src/common/shared_vuejs.ts index d0718473..1e0ff408 100755 --- a/src/common/shared_vuejs.ts +++ b/src/common/shared_vuejs.ts @@ -2303,6 +2303,8 @@ export const shared_consts = { return add + 'grp' + add } else if (table === 'circuits') { return add + 'circuit' + add + } else if (table === 'catalogs') { + return add + 'catalogs' + add } return '' diff --git a/src/components/CAITools/CAITools.ts b/src/components/CAITools/CAITools.ts index c7440ce9..96687344 100755 --- a/src/components/CAITools/CAITools.ts +++ b/src/components/CAITools/CAITools.ts @@ -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, } } }) diff --git a/src/components/CAITools/CAITools.vue b/src/components/CAITools/CAITools.vue index 33e21d09..46be4cce 100755 --- a/src/components/CAITools/CAITools.vue +++ b/src/components/CAITools/CAITools.vue @@ -1,6 +1,6 @@