File size: 512 Bytes
61dac7b
71b93f9
61dac7b
71b93f9
61dac7b
71b93f9
 
 
 
 
 
 
 
61dac7b
71b93f9
61dac7b
71b93f9
61dac7b
71b93f9
61dac7b
71b93f9
 
 
 
 
 
61dac7b
71b93f9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import streamlit as st
from transformers import pipeline

st.title("Mini Chatbot")

@st.cache_resource
def load_model():
    pipe = pipeline(
        "text-generation",
        model="TinyLlama/TinyLlama-1.1B-Chat-v1.0",
        device_map="cpu"
    )
    return pipe

pipe = load_model()

prompt = st.text_input("Your message")

if st.button("Send"):

    output = pipe(
        prompt,
        max_new_tokens=100,
        do_sample=True,
        temperature=0.7
    )

    st.write(output[0]["generated_text"])