File size: 1,334 Bytes
aff3dff
932a3aa
aff3dff
45996ec
 
 
 
 
932a3aa
 
 
aff3dff
932a3aa
aff3dff
932a3aa
 
 
 
45996ec
 
932a3aa
 
aff3dff
45996ec
932a3aa
45996ec
 
932a3aa
 
aff3dff
45996ec
aff3dff
932a3aa
 
45996ec
932a3aa
 
aff3dff
 
45996ec
 
 
 
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import streamlit as st
from transformers import pipeline

# Set Streamlit page configuration
st.set_page_config(page_title="AI Chatbot", layout="centered")

# Load the model pipeline (cached to avoid reloading on each run)
@st.cache_resource
def load_pipeline():
    model_name = "Orenguteng/Llama-3.1-8B-Lexi-Uncensored-V2"
    return pipeline("text-generation", model=model_name)

pipe = load_pipeline()

# App UI
st.title("🤖 AI Chatbot")
st.markdown(
    """
    Welcome to the **AI Chatbot** powered by Hugging Face's **Llama-3.1-8B-Lexi-Uncensored-V2** model.  
    Enter your message below, and the AI will respond!
    """
)

# Input Textbox
user_input = st.text_area(
    "Your Message",
    placeholder="Type your message here...",
    height=100
)

# Generate Button and Response
if st.button("Generate Response"):
    if user_input.strip():
        with st.spinner("Generating response..."):
            # Generate a response
            response = pipe(user_input, max_length=150, num_return_sequences=1)
            st.text_area("Response", value=response[0]['generated_text'], height=200)
    else:
        st.warning("Please enter a message before clicking the button.")

# Footer
st.markdown("---")
st.markdown("Made with ❤️ using [Streamlit](https://streamlit.io) and [Hugging Face](https://huggingface.co).")