- Iniziato a scrivere la CHATBOT...

This commit is contained in:
Surya Paolo
2025-08-09 00:48:44 +02:00
parent 6013a624f6
commit f1f3f5ad07
14 changed files with 186 additions and 68 deletions

View File

@@ -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 = [

View File

@@ -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 {

View File

@@ -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 <a href=\'https://t.me/riso_gruppo/1911\'>RISO RIevoluzione SOlidale</a> (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 <a href=\'https://riso.app/riso_gruppo\'>☀️💚 RISO - Rete Italiana Scambi Orizzontali</a> (Topic \'Annunci RISO\') "
await tools.sendMsgTelegramCmd($q, t, shared_consts.MsgTeleg.SHARE_TEXT, false, mystr)
tools.copyToClip($q, getlinkpage(), true)

View File

@@ -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'],

View File

@@ -974,6 +974,15 @@
</div>
<CAITools></CAITools>
</div>
<div v-else-if="myel.type === shared_consts.ELEMTYPE.CHATBOT">
<div
v-if="editOn"
class="elemEdit"
>
CHATBOT:
</div>
<ChatBot></ChatBot>
</div>
<div v-else-if="myel.type === shared_consts.ELEMTYPE.NOTIFATTOP">
<div
v-if="editOn"

View File

@@ -160,7 +160,6 @@ export default defineComponent({
// console.log('load')
myloadingload.value = true
datastat.value = await globalStore.getStatSite()
datastat.value = {}
eseguipolling.value = true

View File

@@ -0,0 +1,12 @@
.chat-container {
max-height: 400px;
overflow-y: auto;
}
.user {
text-align: right;
}
.bot {
text-align: left;
}

View File

@@ -0,0 +1,45 @@
import type { PropType } from 'vue';
import { computed, defineComponent, ref } from 'vue';
import type { IOperators } from '@model';
import { tools } from '@tools';
import axios from 'axios'
import { useMessageStore, useUserStore } from 'app/src/store';
export default defineComponent({
name: 'ChatBot',
props: {},
setup(props) {
const userMessage = ref<string>('');
const messageStore = useMessageStore()
const messages = ref<Array<{ sender: string; text: string }>>([]);
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,
};
},
});

View File

@@ -0,0 +1,18 @@
<template>
<q-page>
<div class="chat-container">
<div v-for="(message, index) in messages" :key="index" :class="message.sender">
<p>{{ message.text }}</p>
</div>
</div>
<q-input v-model="userMessage" @keyup.enter="sendMessage" label="Scrivi un messaggio" />
</q-page>
</template>
<script lang="ts" src="./ChatBot.ts">
</script>
<style lang="scss" scoped>
@import './ChatBot.scss';
</style>

View File

@@ -0,0 +1 @@
export {default as ChatBot} from './ChatBot.vue'