Allahbux commited on
Commit
45996ec
·
verified ·
1 Parent(s): 932a3aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -10
app.py CHANGED
@@ -1,8 +1,11 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
- # Load the model pipeline
5
- @st.cache_resource # Cache the model to avoid reloading
 
 
 
6
  def load_pipeline():
7
  model_name = "Orenguteng/Llama-3.1-8B-Lexi-Uncensored-V2"
8
  return pipeline("text-generation", model=model_name)
@@ -10,28 +13,31 @@ def load_pipeline():
10
  pipe = load_pipeline()
11
 
12
  # App UI
13
- st.set_page_config(page_title="Hugging Face Chatbot", layout="centered")
14
  st.title("🤖 AI Chatbot")
15
  st.markdown(
16
  """
17
- Welcome to the **AI Chatbot** powered by Hugging Face's Llama-3.1-8B-Lexi-Uncensored-V2 model.
18
- Enter your message below to get started!
19
  """
20
  )
21
 
22
- # Input Box
23
  user_input = st.text_area(
24
- "Your Message",
25
- placeholder="Type your message here...",
26
  height=100
27
  )
28
 
29
- # Generate Button
30
  if st.button("Generate Response"):
31
  if user_input.strip():
32
  with st.spinner("Generating response..."):
 
33
  response = pipe(user_input, max_length=150, num_return_sequences=1)
34
  st.text_area("Response", value=response[0]['generated_text'], height=200)
35
  else:
36
  st.warning("Please enter a message before clicking the button.")
37
-
 
 
 
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
+ # Set Streamlit page configuration
5
+ st.set_page_config(page_title="AI Chatbot", layout="centered")
6
+
7
+ # Load the model pipeline (cached to avoid reloading on each run)
8
+ @st.cache_resource
9
  def load_pipeline():
10
  model_name = "Orenguteng/Llama-3.1-8B-Lexi-Uncensored-V2"
11
  return pipeline("text-generation", model=model_name)
 
13
  pipe = load_pipeline()
14
 
15
  # App UI
 
16
  st.title("🤖 AI Chatbot")
17
  st.markdown(
18
  """
19
+ Welcome to the **AI Chatbot** powered by Hugging Face's **Llama-3.1-8B-Lexi-Uncensored-V2** model.
20
+ Enter your message below, and the AI will respond!
21
  """
22
  )
23
 
24
+ # Input Textbox
25
  user_input = st.text_area(
26
+ "Your Message",
27
+ placeholder="Type your message here...",
28
  height=100
29
  )
30
 
31
+ # Generate Button and Response
32
  if st.button("Generate Response"):
33
  if user_input.strip():
34
  with st.spinner("Generating response..."):
35
+ # Generate a response
36
  response = pipe(user_input, max_length=150, num_return_sequences=1)
37
  st.text_area("Response", value=response[0]['generated_text'], height=200)
38
  else:
39
  st.warning("Please enter a message before clicking the button.")
40
+
41
+ # Footer
42
+ st.markdown("---")
43
+ st.markdown("Made with ❤️ using [Streamlit](https://streamlit.io) and [Hugging Face](https://huggingface.co).")