FredZhang7 commited on
Commit
52faafe
1 Parent(s): 6fc45c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -28
app.py CHANGED
@@ -90,34 +90,6 @@ examples = [
90
  ]
91
 
92
 
93
- def respond(history=None):
94
- global msg, token_count_chat, temperature_chat, top_p_chat, presence_penalty_chat, count_penalty_chat
95
-
96
- # get the lastest user message and the additional parameters
97
- instruction = msg.value
98
- token_count = token_count_chat.value
99
-
100
- temperature = temperature_chat.value
101
- top_p = top_p_chat.value
102
- presence_penalty = presence_penalty_chat.value
103
- count_penalty = count_penalty_chat.value
104
-
105
- history[-1][1] = ""
106
-
107
- for character in generator(
108
- instruction,
109
- None,
110
- token_count,
111
- temperature,
112
- top_p,
113
- presence_penalty,
114
- count_penalty,
115
- history
116
- ):
117
- history[-1][1] += character
118
- yield history
119
-
120
-
121
  def generator(
122
  instruction,
123
  input=None,
@@ -233,6 +205,36 @@ with gr.Blocks(title=title) as demo:
233
  history = history or []
234
  return "", history + [[message, None]]
235
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  msg.submit(user_msg, [msg, chatbot], [msg, chatbot], queue=False).then(
237
  respond, chatbot, chatbot, api_name="chat"
238
  )
 
90
  ]
91
 
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  def generator(
94
  instruction,
95
  input=None,
 
205
  history = history or []
206
  return "", history + [[message, None]]
207
 
208
+ def respond(history=None):
209
+ global msg, token_count_chat, temperature_chat, top_p_chat, presence_penalty_chat, count_penalty_chat
210
+
211
+ # get the lastest user message and the additional parameters
212
+ print("msg.value = ", msg.value)
213
+ print("history = ", history)
214
+
215
+ instruction = msg.value
216
+ token_count = token_count_chat.value
217
+
218
+ temperature = temperature_chat.value
219
+ top_p = top_p_chat.value
220
+ presence_penalty = presence_penalty_chat.value
221
+ count_penalty = count_penalty_chat.value
222
+
223
+ history[-1][1] = ""
224
+
225
+ for character in generator(
226
+ instruction,
227
+ None,
228
+ token_count,
229
+ temperature,
230
+ top_p,
231
+ presence_penalty,
232
+ count_penalty,
233
+ history
234
+ ):
235
+ history[-1][1] += character
236
+ yield history
237
+
238
  msg.submit(user_msg, [msg, chatbot], [msg, chatbot], queue=False).then(
239
  respond, chatbot, chatbot, api_name="chat"
240
  )