diff --git a/1_module copia.jpg b/1_module copia.jpg
new file mode 100644
index 00000000..73aad9f2
Binary files /dev/null and b/1_module copia.jpg differ
diff --git a/src/common/shared_vuejs.ts b/src/common/shared_vuejs.ts
index 4516f9c0..a17a9ae5 100755
--- a/src/common/shared_vuejs.ts
+++ b/src/common/shared_vuejs.ts
@@ -162,6 +162,7 @@ export const shared_consts = {
CATALOGO: 310,
RACCOLTA: 315,
TOOLSAI: 320,
+ CHATBOT: 325,
MAPPA: 350,
MAPPAUTENTI: 360,
MAPPACOMUNI: 370,
@@ -1976,6 +1977,14 @@ export const shared_consts = {
value: 315,
label: 'RACCOLTA CATALOGHI',
},
+ {
+ value: 320,
+ label: 'TOOLS AI',
+ },
+ {
+ value: 325,
+ label: 'CHATBOT',
+ },
{
value: 350,
label: 'MAPPA',
diff --git a/src/components/CAITools/CAITools.ts b/src/components/CAITools/CAITools.ts
index c39f6988..8240cda8 100755
--- a/src/components/CAITools/CAITools.ts
+++ b/src/components/CAITools/CAITools.ts
@@ -40,6 +40,8 @@ export default defineComponent({
]
const modelList = [
{ label: 'DeepSeek', value: 'deepseek-chat' },
+ { label: 'Gemma-2B', value: 'gemma:2b' },
+ { label: 'Gemma3', value: 'gemma3:12b' },
]
const outputTypeList = [
diff --git a/src/components/CImportListaTitoli/CImportListaTitoli.ts b/src/components/CImportListaTitoli/CImportListaTitoli.ts
index 104fd07f..f5d665e5 100755
--- a/src/components/CImportListaTitoli/CImportListaTitoli.ts
+++ b/src/components/CImportListaTitoli/CImportListaTitoli.ts
@@ -103,7 +103,6 @@ export default defineComponent({
const filter = ref('');
-
const importSelectedBooks = () => {
if (searchResults.value.length === 0) {
$q.notify({
@@ -116,9 +115,8 @@ export default defineComponent({
// Aggiungi i libri selezionati alla lista dell'utente
emit(
'addArrayTitlesToList',
- searchResults.value.filter((row) => row.select),
+ searchResults.value.filter((row) => row.select)
);
-
};
const pagination = reactive({
@@ -197,7 +195,6 @@ export default defineComponent({
color: 'negative',
});
}
-
} catch (err) {
error.value = 'Errore nella ricerca dei libri';
} finally {
@@ -289,9 +286,7 @@ export default defineComponent({
}
function deselectAll() {
-
searchResults.value.forEach((row) => (row.select = false));
-
}
return {
diff --git a/src/components/CMyCardService/CMyCardService.ts b/src/components/CMyCardService/CMyCardService.ts
index 14eed271..258b7941 100644
--- a/src/components/CMyCardService/CMyCardService.ts
+++ b/src/components/CMyCardService/CMyCardService.ts
@@ -647,7 +647,7 @@ export default defineComponent({
}
async function condividi() {
- const mystr = "❇️ Ecco l'annuncio da condividere !\nPuoi copiarlo oppure inoltrarlo a chi vuoi.\n\nE\' utile pubblicarlo anche nel gruppo Telegram RISO territoriale o in RISO RIevoluzione SOlidale (Topic \'Annunci RISO\') "
+ const mystr = "❇️ Ecco l'annuncio da condividere !\nPuoi copiarlo oppure inoltrarlo a chi vuoi.\n\nE\' utile pubblicarlo anche nel gruppo Telegram RISO territoriale o in ☀️💚 RISO - Rete Italiana Scambi Orizzontali (Topic \'Annunci RISO\') "
await tools.sendMsgTelegramCmd($q, t, shared_consts.MsgTeleg.SHARE_TEXT, false, mystr)
tools.copyToClip($q, getlinkpage(), true)
diff --git a/src/components/CMyElem/CMyElem.ts b/src/components/CMyElem/CMyElem.ts
index a013af77..688855e8 100755
--- a/src/components/CMyElem/CMyElem.ts
+++ b/src/components/CMyElem/CMyElem.ts
@@ -12,6 +12,7 @@ import { CImgTitle } from '../CImgTitle/index'
import { CImgPoster } from '@src/components/CImgPoster'
import { CTitle } from '@src/components/CTitle/index'
import { CGridOriz } from '@src/components/CGridOriz/index'
+import { ChatBot } from '@src/components/ChatBot/index'
import { CCatalogList } from '@src/components/CCatalogList/index'
import { CRaccoltaCataloghi } from '@src/components/CRaccoltaCataloghi/index'
import { tools } from '@tools'
@@ -80,6 +81,7 @@ export default defineComponent({
CMapComuni, CMapUsers, CMapGetCoordinates, CMapEditAddressByCoord,
CDashGroup, CMovements, CGridOriz, CQRCode, CCatalogList,
CSearchProduct, CRaccoltaCataloghi, CPageViewStats,
+ ChatBot,
// , //CMapMarker,
},
emits: ['selElemClick'],
diff --git a/src/components/CMyElem/CMyElem.vue b/src/components/CMyElem/CMyElem.vue
index f9a05df6..1f96b623 100755
--- a/src/components/CMyElem/CMyElem.vue
+++ b/src/components/CMyElem/CMyElem.vue
@@ -974,6 +974,15 @@
+
('');
+ const messageStore = useMessageStore()
+ const messages = ref
>([]);
+
+ const sendMessage = async () => {
+ if (userMessage.value.trim()) {
+ messages.value.push({ sender: 'user', text: userMessage.value });
+
+ try {
+ const response = await messageStore.chatBot({
+ message: userMessage.value,
+ })
+ const botMessage = response[0]?.text || 'Non ho capito';
+ messages.value.push({ sender: 'bot', text: botMessage });
+ } catch (error) {
+ console.error('Errore nella comunicazione con il backend', error);
+ messages.value.push({ sender: 'bot', text: 'Errore di comunicazione' });
+ }
+
+ userMessage.value = '';
+ }
+ };
+
+ return {
+ tools,
+ userMessage,
+ messages,
+ sendMessage,
+ };
+ },
+});
diff --git a/src/components/ChatBot/ChatBot.vue b/src/components/ChatBot/ChatBot.vue
new file mode 100755
index 00000000..53eca94c
--- /dev/null
+++ b/src/components/ChatBot/ChatBot.vue
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/ChatBot/index.ts b/src/components/ChatBot/index.ts
new file mode 100755
index 00000000..5eef20f9
--- /dev/null
+++ b/src/components/ChatBot/index.ts
@@ -0,0 +1 @@
+export {default as ChatBot} from './ChatBot.vue'
diff --git a/src/statics/lang/it.js b/src/statics/lang/it.js
index fd7a716c..e969ebd6 100755
--- a/src/statics/lang/it.js
+++ b/src/statics/lang/it.js
@@ -1267,6 +1267,7 @@ const msg_it = {
isTemplate: 'E\' un modello',
catAI: 'Categorie AI',
toolsAI: 'Strumenti AI',
+ CHATBOT: 'Chat BOT',
aitools: 'Ricerca',
queryAI: 'Query AI',
admin_ai: 'Gestione AI',
diff --git a/src/store/MessageStore.ts b/src/store/MessageStore.ts
index a2033dbe..5bd0bec0 100755
--- a/src/store/MessageStore.ts
+++ b/src/store/MessageStore.ts
@@ -1,14 +1,14 @@
-import { defineStore } from 'pinia'
-import { Api } from '@api'
+import { defineStore } from 'pinia';
+import { Api } from '@api';
-import { serv_constants } from './Modules/serv_constants'
+import { serv_constants } from './Modules/serv_constants';
-import type { IMessage, IMessageState, IMsgUsers} from '../model';
-import { StatusMessage } from '../model'
-import { tools } from '@src/store/Modules/tools'
-import { MsgDefault } from '@src/model'
-import { shared_consts } from '@src/common/shared_vuejs'
-import { useUserStore } from '@store/UserStore'
+import type { IMessage, IMessageState, IMsgUsers } from '../model';
+import { StatusMessage } from '../model';
+import { tools } from '@src/store/Modules/tools';
+import { MsgDefault } from '@src/model';
+import { shared_consts } from '@src/common/shared_vuejs';
+import { useUserStore } from '@store/UserStore';
export const useMessageStore = defineStore('MessageStore', {
state: (): IMessageState => ({
@@ -17,57 +17,57 @@ export const useMessageStore = defineStore('MessageStore', {
}),
getters: {
-
getlasts_messages: (mystate: IMessageState) => (): IMessage[] => {
- const ctrec = (mystate.last_msgs) ? mystate.last_msgs.slice(0, 5) : []
+ const ctrec = mystate.last_msgs ? mystate.last_msgs.slice(0, 5) : [];
// const ctrec = (mystate.msgs) ? mystate.msgs.slice().reverse().slice(0, 5) : []
- return (ctrec)
-
+ return ctrec;
},
getnumMsgUnread: (mystate: IMessageState) => () => {
- return mystate.last_msgs.filter((msg) => !msg.read).length
+ return mystate.last_msgs.filter((msg) => !msg.read).length;
},
-
},
actions: {
-
setMsg(arrmsg: IMessage[], username: string) {
// console.log('arrmsg', arrmsg)
- const userStore = useUserStore()
+ const userStore = useUserStore();
if (arrmsg.length > 0) {
- let users_msg: any = this.users_msg.find((rec: IMsgUsers) => rec.username === username)
+ let users_msg: any = this.users_msg.find(
+ (rec: IMsgUsers) => rec.username === username
+ );
if (!users_msg) {
- this.users_msg.push({ username, msgs: [] })
- users_msg = this.users_msg.find((rec) => rec.username === username)
+ this.users_msg.push({ username, msgs: [] });
+ users_msg = this.users_msg.find((rec) => rec.username === username);
}
- users_msg.msgs.push(...arrmsg)
+ users_msg.msgs.push(...arrmsg);
// console.table(users_msg.msgs)
// users_msg.msgs = tools.getUnique(users_msg.msgs, '_id')
// console.table(users_msg.msgs)
if (users_msg.msgs) {
- let userother: any = users_msg.msgs.slice(-1)[0].dest
+ let userother: any = users_msg.msgs.slice(-1)[0].dest;
if (userother === userStore.my.username)
- userother = users_msg.msgs.slice(-1)[0].origin
+ userother = users_msg.msgs.slice(-1)[0].origin;
- let index = this.last_msgs.findIndex((rec: IMessage) => (rec.dest === userother) || (rec.origin === userother))
+ let index = this.last_msgs.findIndex(
+ (rec: IMessage) => rec.dest === userother || rec.origin === userother
+ );
if (index >= 0) {
// Update last message
- this.last_msgs[index] = users_msg.msgs.slice(-1)[0]
+ this.last_msgs[index] = users_msg.msgs.slice(-1)[0];
} else {
- this.last_msgs.push(users_msg.msgs.slice(-1)[0])
- index = this.last_msgs.findIndex((rec: IMessage) => (rec.dest === userother) || (rec.origin === userother))
+ this.last_msgs.push(users_msg.msgs.slice(-1)[0]);
+ index = this.last_msgs.findIndex(
+ (rec: IMessage) => rec.dest === userother || rec.origin === userother
+ );
}
if (this.last_msgs[index])
- users_msg.lastdataread = this.last_msgs[index].datemsg
- else
- users_msg.lastdataread = tools.getLastDateReadReset()
-
+ users_msg.lastdataread = this.last_msgs[index].datemsg;
+ else users_msg.lastdataread = tools.getLastDateReadReset();
} else {
- users_msg.lastdataread = tools.getLastDateReadReset()
+ users_msg.lastdataread = tools.getLastDateReadReset();
}
// console.log('RICeVUTO', arrmsg, 'lastdataread', users_msg.lastdataread)
@@ -75,39 +75,55 @@ export const useMessageStore = defineStore('MessageStore', {
}
},
- async updateMsgDataFromServer({ username, lastdataread }: { username: string, lastdataread: Date }) {
+ async updateMsgDataFromServer({
+ username,
+ lastdataread,
+ }: {
+ username: string;
+ lastdataread: Date;
+ }) {
// console.log('updateMsgDataFromServer', username, lastdataread)
- return Api.SendReq(`/sendmsg/${username}/${lastdataread}/${tools.getEnv('VITE_APP_ID')}`, 'GET', null)
+ return Api.SendReq(
+ `/sendmsg/${username}/${lastdataread}/${tools.getEnv('VITE_APP_ID')}`,
+ 'GET',
+ null
+ )
.then((res) => {
// console.log('res', res)
if (res.status === 200) {
- this.setMsg(res.data.arrmsg, username)
- return true
+ this.setMsg(res.data.arrmsg, username);
+ return true;
}
- return false
+ return false;
})
.catch((error) => {
- console.error(error)
- return false
- })
+ console.error(error);
+ return false;
+ });
},
async SendMsgEvent(msg: IMessage) {
- console.log('SendMsgEvent', msg)
+ console.log('SendMsgEvent', msg);
- const data: IMessage = { ...MsgDefault, ...msg }
+ const data: IMessage = { ...MsgDefault, ...msg };
- const userStore = useUserStore()
+ const userStore = useUserStore();
- data.source!.page = ''
- data.idapp = tools.getEnv('VITE_APP_ID')
- data.origin = userStore.my.username
- data.datemsg = tools.getDateNow()
- data.status = StatusMessage.WaitingToSend
+ data.source!.page = '';
+ data.idapp = tools.getEnv('VITE_APP_ID');
+ data.origin = userStore.my.username;
+ data.datemsg = tools.getDateNow();
+ data.status = StatusMessage.WaitingToSend;
// Options
- data.typesend = tools.SetBit(data.typesend, shared_consts.MessageOptions.Notify_ByEmail)
- data.typesend = tools.SetBit(data.typesend, shared_consts.MessageOptions.Notify_ByPushNotification)
+ data.typesend = tools.SetBit(
+ data.typesend,
+ shared_consts.MessageOptions.Notify_ByEmail
+ );
+ data.typesend = tools.SetBit(
+ data.typesend,
+ shared_consts.MessageOptions.Notify_ByPushNotification
+ );
// console.log('DOPO:')
// console.table(data)
@@ -117,21 +133,30 @@ export const useMessageStore = defineStore('MessageStore', {
// console.log('res', res)
if (res.status === 200) {
if (res.data.code === serv_constants.RIS_CODE_OK) {
- data._id = res.data.id
+ data._id = res.data.id;
- const myarr = []
- myarr.push(data)
+ const myarr = [];
+ myarr.push(data);
- this.setMsg(myarr, data.dest)
- return true
+ this.setMsg(myarr, data.dest);
+ return true;
}
}
- return false
+ return false;
})
.catch((error) => {
- console.error(error)
- return false
- })
+ console.error(error);
+ return false;
+ });
+ },
+ async chatBot(payload: any): Promise {
+ const response = await Api.SendReq('/api/chatbot', 'POST', { payload });
+
+ if (response.status !== 200) {
+ throw new Error('Errore nella risposta del server');
+ }
+
+ return response.data; // Supponiamo che il backend ritorni un array di oggetti con id e title
},
},
-})
+});