yizhangliu commited on
Commit
5645dcc
β€’
1 Parent(s): ef6017f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -6
app.py CHANGED
@@ -187,7 +187,6 @@ start_work = """async() => {
187
  window['chat_bot1'].style.height = new_height;
188
  window['chat_bot1'].children[1].style.height = new_height;
189
  window['chat_bot1'].children[0].style.top = (parseInt(window['chat_bot1'].style.height)-window['chat_bot1'].children[0].offsetHeight-2) + 'px';
190
-
191
  prompt_row.children[0].style.flex = 'auto';
192
  prompt_row.children[0].style.width = '100%';
193
  window['gradioEl'].querySelectorAll('#chat_radio')[0].style.flex = 'auto';
@@ -234,7 +233,6 @@ start_work = """async() => {
234
  try {
235
  if (window['chat_radio_0'].checked) {
236
  dot_flashing = window['chat_bot'].children[1].children[0].querySelectorAll('.dot-flashing');
237
-
238
  if (window['chat_bot'].children[1].children[0].children.length > window['div_count'] && dot_flashing.length == 0) {
239
  new_len = window['chat_bot'].children[1].children[0].children.length - window['div_count'];
240
  for (var i = 0; i < new_len; i++) {
@@ -256,7 +254,6 @@ start_work = """async() => {
256
  img_index = 0;
257
  draw_prompt_en = window['my_prompt_en'].value;
258
  if (window['doCheckPrompt'] == 0 && window['prevPrompt'] != draw_prompt_en) {
259
-
260
  console.log('_____draw_prompt_en___[' + draw_prompt_en + ']_');
261
  window['doCheckPrompt'] = 1;
262
  window['prevPrompt'] = draw_prompt_en;
@@ -287,7 +284,6 @@ start_work = """async() => {
287
  user_div.dataset.testid = 'user';
288
  user_div.innerHTML = "<p>δ½œη”»: " + window['draw_prompt'] + "</p><img></img>";
289
  window['chat_bot1'].children[1].children[0].appendChild(user_div);
290
-
291
  var bot_div = document.createElement("div");
292
  bot_div.className = "message bot svelte-134zwfa";
293
  bot_div.style.backgroundColor = "#2563eb";
@@ -429,7 +425,7 @@ def get_response_from_openai(input, chat_history, model_radio):
429
  ret = f"Openai said: {e} Perhaps enter your OpenAI API key."
430
  return ret, {"completion_tokens": -1, "prompt_tokens": -1, "total_tokens": -1}
431
 
432
- print(f'chat_history = {chat_history}')
433
  chat_history_list = []
434
  chat_history = chat_history.replace("<p>", "").replace("</p>", "")
435
  if chat_history != '':
@@ -437,7 +433,7 @@ def get_response_from_openai(input, chat_history, model_radio):
437
  chat_history_list.append(f'☟:{input}')
438
 
439
  output, response_usage = openai_create(chat_history_list, model_radio)
440
- print(f'response_usage={response_usage}')
441
  return output
442
 
443
  def chat(input0, input1, chat_radio, model_radio, all_chat_history, chat_history):
 
187
  window['chat_bot1'].style.height = new_height;
188
  window['chat_bot1'].children[1].style.height = new_height;
189
  window['chat_bot1'].children[0].style.top = (parseInt(window['chat_bot1'].style.height)-window['chat_bot1'].children[0].offsetHeight-2) + 'px';
 
190
  prompt_row.children[0].style.flex = 'auto';
191
  prompt_row.children[0].style.width = '100%';
192
  window['gradioEl'].querySelectorAll('#chat_radio')[0].style.flex = 'auto';
 
233
  try {
234
  if (window['chat_radio_0'].checked) {
235
  dot_flashing = window['chat_bot'].children[1].children[0].querySelectorAll('.dot-flashing');
 
236
  if (window['chat_bot'].children[1].children[0].children.length > window['div_count'] && dot_flashing.length == 0) {
237
  new_len = window['chat_bot'].children[1].children[0].children.length - window['div_count'];
238
  for (var i = 0; i < new_len; i++) {
 
254
  img_index = 0;
255
  draw_prompt_en = window['my_prompt_en'].value;
256
  if (window['doCheckPrompt'] == 0 && window['prevPrompt'] != draw_prompt_en) {
 
257
  console.log('_____draw_prompt_en___[' + draw_prompt_en + ']_');
258
  window['doCheckPrompt'] = 1;
259
  window['prevPrompt'] = draw_prompt_en;
 
284
  user_div.dataset.testid = 'user';
285
  user_div.innerHTML = "<p>δ½œη”»: " + window['draw_prompt'] + "</p><img></img>";
286
  window['chat_bot1'].children[1].children[0].appendChild(user_div);
 
287
  var bot_div = document.createElement("div");
288
  bot_div.className = "message bot svelte-134zwfa";
289
  bot_div.style.backgroundColor = "#2563eb";
 
425
  ret = f"Openai said: {e} Perhaps enter your OpenAI API key."
426
  return ret, {"completion_tokens": -1, "prompt_tokens": -1, "total_tokens": -1}
427
 
428
+ # logger.info(f'chat_history = {chat_history}')
429
  chat_history_list = []
430
  chat_history = chat_history.replace("<p>", "").replace("</p>", "")
431
  if chat_history != '':
 
433
  chat_history_list.append(f'☟:{input}')
434
 
435
  output, response_usage = openai_create(chat_history_list, model_radio)
436
+ logger.info(f'response_usage={response_usage}')
437
  return output
438
 
439
  def chat(input0, input1, chat_radio, model_radio, all_chat_history, chat_history):