CogwiseAI commited on
Commit
fa20b68
·
1 Parent(s): 67d9e54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -76,8 +76,8 @@ st.markdown("""
76
  # Load the model outside the handle_input() function
77
  with open('model_saved.pkl', 'rb') as f:
78
  model = pickle.load(f)
79
- if not hasattr(model, 'predict'):
80
- st.error("The loaded model does not have a predict method.")
81
 
82
  def write_top_bar():
83
  col1, col2, col3 = st.columns([1,10,2])
@@ -110,11 +110,8 @@ def handle_input():
110
  if len(chat_history) == MAX_HISTORY_LENGTH:
111
  chat_history = chat_history[:-1]
112
 
113
- def generate_response(question: str) -> str:
114
- return model.predict([question])[0]
115
-
116
  prompt = input
117
- answer = generate_response(prompt)
118
 
119
  chat_history.append((input, answer))
120
 
 
76
  # Load the model outside the handle_input() function
77
  with open('model_saved.pkl', 'rb') as f:
78
  model = pickle.load(f)
79
+ if not isinstance(model, str):
80
+ st.error("The loaded model is not valid.")
81
 
82
  def write_top_bar():
83
  col1, col2, col3 = st.columns([1,10,2])
 
110
  if len(chat_history) == MAX_HISTORY_LENGTH:
111
  chat_history = chat_history[:-1]
112
 
 
 
 
113
  prompt = input
114
+ answer = model # Replace the predict() method with the model itself
115
 
116
  chat_history.append((input, answer))
117