Spaces:
Running
Running
gorkemgoknar
commited on
Commit
•
07cd099
1
Parent(s):
418119a
Update app.py
Browse files
app.py
CHANGED
@@ -92,12 +92,12 @@ def get_chat_response(name,history=[], input_txt = "Hello , what is your name?")
|
|
92 |
|
93 |
|
94 |
|
95 |
-
def greet(character,message):
|
96 |
|
97 |
#gradios set_state/get_state had problems on embedded html!
|
98 |
-
|
99 |
#gradios set_state/get_state does not persist session for now using global
|
100 |
-
global history
|
101 |
|
102 |
if history["character"] != character:
|
103 |
#switching character
|
@@ -116,7 +116,7 @@ def greet(character,message):
|
|
116 |
html += f"<div class='resp_msg'>{character}: {resp_msg}</div>"
|
117 |
html += "</div>"
|
118 |
|
119 |
-
return html
|
120 |
|
121 |
|
122 |
|
@@ -142,7 +142,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"], outputs="html",css=css, title=title, description=description,article=article )
|
146 |
|
147 |
|
148 |
if __name__ == "__main__":
|
|
|
92 |
|
93 |
|
94 |
|
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 |
|
102 |
if history["character"] != character:
|
103 |
#switching character
|
|
|
116 |
html += f"<div class='resp_msg'>{character}: {resp_msg}</div>"
|
117 |
html += "</div>"
|
118 |
|
119 |
+
return html,history
|
120 |
|
121 |
|
122 |
|
|
|
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__":
|