Spaces:
Sleeping
Sleeping
Samuel L Meyers
commited on
Commit
·
3b72dcd
1
Parent(s):
3478db7
Add chat window
Browse files- code/app.py +6 -2
code/app.py
CHANGED
@@ -24,6 +24,9 @@ otxt = ""
|
|
24 |
def m3b_talk(text):
|
25 |
global otxt
|
26 |
resp = ""
|
|
|
|
|
|
|
27 |
formattedQuery = "GPT4 User: " + text + "<|end_of_text|>GPT4 Assistant:"
|
28 |
r = lcpp_model(formattedQuery, stop=["GPT4 User:", "\n\n\n"], echo=True, stream=True)
|
29 |
rfq = False
|
@@ -31,6 +34,7 @@ def m3b_talk(text):
|
|
31 |
otxt += c["choices"][0]["text"]
|
32 |
if formattedQuery in otxt and not rfq:
|
33 |
otxt.replace(formattedQuery, "")
|
|
|
34 |
rfq = True
|
35 |
else:
|
36 |
yield otxt
|
@@ -45,10 +49,10 @@ def main():
|
|
45 |
with gr.Blocks() as demo:
|
46 |
with gr.Row(variant="panel"):
|
47 |
gr.Markdown("## Talk to Starling 7B\n")
|
48 |
-
with gr.Row(variant="panel"):
|
49 |
-
m3b_talk_input = gr.Textbox(label="Message", placeholder="Type something here...")
|
50 |
with gr.Row(variant="panel"):
|
51 |
m3b_talk_output = gr.Textbox()
|
|
|
|
|
52 |
with gr.Row(variant="panel"):
|
53 |
m3b_talk_btn = gr.Button("Send")
|
54 |
|
|
|
24 |
def m3b_talk(text):
|
25 |
global otxt
|
26 |
resp = ""
|
27 |
+
if otxt != "":
|
28 |
+
otxt += "\n\n"
|
29 |
+
otxt += "<User>: " + text
|
30 |
formattedQuery = "GPT4 User: " + text + "<|end_of_text|>GPT4 Assistant:"
|
31 |
r = lcpp_model(formattedQuery, stop=["GPT4 User:", "\n\n\n"], echo=True, stream=True)
|
32 |
rfq = False
|
|
|
34 |
otxt += c["choices"][0]["text"]
|
35 |
if formattedQuery in otxt and not rfq:
|
36 |
otxt.replace(formattedQuery, "")
|
37 |
+
otxt += "\n\n<Assistant>: "
|
38 |
rfq = True
|
39 |
else:
|
40 |
yield otxt
|
|
|
49 |
with gr.Blocks() as demo:
|
50 |
with gr.Row(variant="panel"):
|
51 |
gr.Markdown("## Talk to Starling 7B\n")
|
|
|
|
|
52 |
with gr.Row(variant="panel"):
|
53 |
m3b_talk_output = gr.Textbox()
|
54 |
+
with gr.Row(variant="panel"):
|
55 |
+
m3b_talk_input = gr.Textbox(label="Message", placeholder="Type something here...")
|
56 |
with gr.Row(variant="panel"):
|
57 |
m3b_talk_btn = gr.Button("Send")
|
58 |
|