Aspik101 commited on
Commit
2381ed3
1 Parent(s): e0adcda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -32,9 +32,19 @@ with gr.Blocks() as demo:
32
  def user(user_message, history):
33
  return "", history + [[user_message, None]]
34
 
 
 
 
 
 
 
 
 
35
  def bot(history):
36
- save_log("question", history)
37
- stream = llm(prompt = f"Jesteś AI assystentem. Odpowiadaj po polsku. <user>: {history}. <assistant>:", **params)
 
 
38
  history[-1][1] = ""
39
  answer_save = ""
40
  for character in stream:
@@ -43,7 +53,7 @@ with gr.Blocks() as demo:
43
  time.sleep(0.005)
44
  yield history
45
 
46
- save_log("answer", answer_save)
47
  msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
48
  bot, chatbot, chatbot
49
  )
 
32
  def user(user_message, history):
33
  return "", history + [[user_message, None]]
34
 
35
+ def parse_history(hist):
36
+ history_ = ""
37
+ for q, a in hist:
38
+ history_ += f"<user>: {q } \n"
39
+ if a:
40
+ history_ += f"<assistant>: {a} \n"
41
+ return history_
42
+
43
  def bot(history):
44
+ print("history: ",history)
45
+ prompt = f"Jesteś AI assystentem. Odpowiadaj po polsku. {parse_history(history)}. <assistant>:"
46
+ print("prompt: ",prompt)
47
+ stream = llm(prompt, **params)
48
  history[-1][1] = ""
49
  answer_save = ""
50
  for character in stream:
 
53
  time.sleep(0.005)
54
  yield history
55
 
56
+ print("answer_save: ",answer_save)
57
  msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
58
  bot, chatbot, chatbot
59
  )