File size: 570 Bytes
a461225
 
 
 
 
 
c6776d9
a461225
 
 
 
c6776d9
a461225
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import streamlit as st
from transformers import pipeline

# Carica il modello AI
@st.cache_resource
def load_model():
    return pipeline("text-generation", model="ibm-granite/granite-3.2-2b-instruct")

chatbot = load_model()

# UI del sito
st.title("💬 Chatbot AI")
st.write("Scrivi un messaggio e il chatbot risponderà!")

# Input utente
user_input = st.text_input("Tu:", "")

if st.button("Invia"):
    if user_input:
        response = chatbot(user_input, max_length=200, do_sample=True)
        st.text_area("Chatbot:", response[0]["generated_text"], height=200)