Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
37 |
-
|
|
|
|
|
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 |
-
|
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 |
)
|