Tharwat-Elsayed commited on
Commit
de01245
·
verified ·
1 Parent(s): ffcb03a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -1,8 +1,13 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
- # Initialize the model
5
- pipe = pipeline("text2text-generation", model="facebook/blenderbot-400M-distill")
 
 
 
 
 
6
  conversation_history = ""
7
 
8
  # Define the conversation function
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
+ # Cache the model pipeline to avoid reloading it on each rerun
5
+ @st.cache_resource
6
+ def load_model():
7
+ return pipeline("text2text-generation", model="facebook/blenderbot-400M-distill")
8
+
9
+ # Load the model (cached)
10
+ pipe = load_model()
11
  conversation_history = ""
12
 
13
  # Define the conversation function