gorkemgoknar commited on
Commit
80709e4
1 Parent(s): 07cd099

Update app.py

Browse files

edit per depreciateion https://gradio.app/advanced_interface_features/

Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -95,7 +95,7 @@ def get_chat_response(name,history=[], input_txt = "Hello , what is your name?")
95
  def greet(character,message,history):
96
 
97
  #gradios set_state/get_state had problems on embedded html!
98
- history = gr.get_state() or {"character": character, "message_history" : [] }
99
  #gradios set_state/get_state does not persist session for now using global
100
  #global history
101
 
@@ -107,7 +107,6 @@ def greet(character,message,history):
107
  response = get_chat_response(character,history=history["message_history"],input_txt=message)
108
 
109
  history["message_history"].append((message, response))
110
- gr.set_state(history)
111
 
112
 
113
  html = "<div class='chatbot'>"
@@ -142,7 +141,7 @@ article = "<p style='text-align: center'><a href='https://www.linkedin.com/pulse
142
  ##interface = gr.Interface(fn=greet, inputs=[gr.inputs.Dropdown(personality_choices) ,"text"], title=title, description=description, outputs="text")
143
 
144
  history = {"character": "None", "message_history" : [] }
145
- interface= gr.Interface(fn=greet, inputs=[gr.inputs.Dropdown(personality_choices) ,"text", history ], outputs=["html",history ],css=css, title=title, description=description,article=article )
146
 
147
 
148
  if __name__ == "__main__":
 
95
  def greet(character,message,history):
96
 
97
  #gradios set_state/get_state had problems on embedded html!
98
+ history = history or {"character": character, "message_history" : [] }
99
  #gradios set_state/get_state does not persist session for now using global
100
  #global history
101
 
 
107
  response = get_chat_response(character,history=history["message_history"],input_txt=message)
108
 
109
  history["message_history"].append((message, response))
 
110
 
111
 
112
  html = "<div class='chatbot'>"
 
141
  ##interface = gr.Interface(fn=greet, inputs=[gr.inputs.Dropdown(personality_choices) ,"text"], title=title, description=description, outputs="text")
142
 
143
  history = {"character": "None", "message_history" : [] }
144
+ interface= gr.Interface(fn=greet, inputs=[gr.inputs.Dropdown(personality_choices) ,"text", "state"], outputs=["html","state"],css=css, title=title, description=description,article=article )
145
 
146
 
147
  if __name__ == "__main__":