yxmauw commited on
Commit
64e9c35
·
verified ·
1 Parent(s): f51410a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -102,12 +102,14 @@ def generate_text(input_text, selected_model):
102
  # Define the chatbot function
103
  def generate_response(model_name, message, chat_history):
104
  model = load_model(model_name)
105
- if chat_history:
106
- input_text = chat_history + " " + message
 
 
107
  else:
108
  input_text = message
109
  response = model.generate(input_text, max_tokens=100)
110
- chat_history.append((message, response))
111
  return chat_history, response
112
 
113
  # Create the Gradio interface
 
102
  # Define the chatbot function
103
  def generate_response(model_name, message, chat_history):
104
  model = load_model(model_name)
105
+ chat_history = [] # list of strings
106
+ if len(chat_history) > 0:
107
+ chat_concat = ", ".join(chat_history)
108
+ input_text = chat_concat + " " + message
109
  else:
110
  input_text = message
111
  response = model.generate(input_text, max_tokens=100)
112
+ chat_history.append((input_text, response))
113
  return chat_history, response
114
 
115
  # Create the Gradio interface