awacke1 commited on
Commit
8753e67
1 Parent(s): e38c256

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -15
app.py CHANGED
@@ -92,31 +92,18 @@ def get_chat_response(name,history=[], input_txt = "Hello , what is your name?")
92
 
93
 
94
  def greet(character,message,history):
95
-
96
- #gradios set_state/get_state had problems on embedded html!
97
  history = history or {"character": character, "message_history" : [] }
98
- #gradios set_state/get_state does not persist session for now using global
99
- #global history
100
-
101
  if history["character"] != character:
102
- #switching character
103
  history = {"character": character, "message_history" : [] }
104
-
105
-
106
  response = get_chat_response(character,history=history["message_history"],input_txt=message)
107
-
108
  history["message_history"].append((message, response))
109
-
110
-
111
  html = "<div class='chatbot'>"
112
  for user_msg, resp_msg in history["message_history"]:
113
  html += f"<div class='user_msg'>You: {user_msg}</div>"
114
  html += f"<div class='resp_msg'>{character}: {resp_msg}</div>"
115
  html += "</div>"
116
-
117
  return html,history
118
 
119
-
120
 
121
  personality_choices = ["Gandalf", "Riddick", "Macleod", "Morpheus", "Neo","Spock","Vader","Indy"]
122
 
@@ -132,8 +119,8 @@ css="""
132
 
133
  #some selected ones are in for demo use
134
  personality_choices = ["Gandalf", "Riddick", "Macleod", "Morpheus", "Neo","Spock","Vader","Indy", "Ig-11","Threepio","Tony Stark","Batman","Vizzini"]
135
- title = "Metayazar - Movie Chatbot"
136
- description = "Chat with your favorite movie characters. This space demo has simple interface and simple history as gradio's state did not work need to make a global history, you will have different responses as same gradio machine will be used! Test it out in metayazar.com/chatbot for more movie/character options and history memorized."
137
  article = "<p style='text-align: center'><a href='https://www.linkedin.com/pulse/ai-goes-job-interview-g%C3%B6rkem-g%C3%B6knar/' target='_blank'>AI Goes to Job Interview</a> | <a href='https://www.metayazar.com/' target='_blank'>Metayazar AI Writer</a> |<a href='https://www.linkedin.com/in/goknar/' target='_blank'>Görkem Göknar</a></p>"
138
 
139
  #History not implemented in this demo, use metayazar.com/chatbot for a movie and character dropdown chat interface
 
92
 
93
 
94
  def greet(character,message,history):
 
 
95
  history = history or {"character": character, "message_history" : [] }
 
 
 
96
  if history["character"] != character:
 
97
  history = {"character": character, "message_history" : [] }
 
 
98
  response = get_chat_response(character,history=history["message_history"],input_txt=message)
 
99
  history["message_history"].append((message, response))
 
 
100
  html = "<div class='chatbot'>"
101
  for user_msg, resp_msg in history["message_history"]:
102
  html += f"<div class='user_msg'>You: {user_msg}</div>"
103
  html += f"<div class='resp_msg'>{character}: {resp_msg}</div>"
104
  html += "</div>"
 
105
  return html,history
106
 
 
107
 
108
  personality_choices = ["Gandalf", "Riddick", "Macleod", "Morpheus", "Neo","Spock","Vader","Indy"]
109
 
 
119
 
120
  #some selected ones are in for demo use
121
  personality_choices = ["Gandalf", "Riddick", "Macleod", "Morpheus", "Neo","Spock","Vader","Indy", "Ig-11","Threepio","Tony Stark","Batman","Vizzini"]
122
+ title = "Chatbot Personalities"
123
+ description = "Characters include | Macleod| Ramirez | Peter Parker | Vizzini | Fezzik | Cornelius | Agent Smith | Korben | Deckard | Plissken | Steve Rogers | Tony Stark | Riddler | Kirk | Spock | Sybok | Scotty | Threepio | Luke | Leia | Ben | Han | Qui-Gon ."
124
  article = "<p style='text-align: center'><a href='https://www.linkedin.com/pulse/ai-goes-job-interview-g%C3%B6rkem-g%C3%B6knar/' target='_blank'>AI Goes to Job Interview</a> | <a href='https://www.metayazar.com/' target='_blank'>Metayazar AI Writer</a> |<a href='https://www.linkedin.com/in/goknar/' target='_blank'>Görkem Göknar</a></p>"
125
 
126
  #History not implemented in this demo, use metayazar.com/chatbot for a movie and character dropdown chat interface