Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ MY_HF_TOKEN_KEY = os.environ["MY_HF_TOKEN_KEY"]
|
|
7 |
#iface = gr.load(name="Ghana-NLP/Khaya-chat-bot",hf_token=MY_HF_TOKEN_KEY,src ='spaces')
|
8 |
client = Client("Ghana-NLP/Khaya-chat-backend",hf_token=MY_HF_TOKEN_KEY)
|
9 |
|
|
|
10 |
def generate(prompt,history,language):
|
11 |
history.append("USER: "+prompt+"\n-----\n")
|
12 |
output = client.predict(prompt,language)
|
@@ -16,7 +17,7 @@ def generate(prompt,history,language):
|
|
16 |
full_output = full_output + el
|
17 |
return history,full_output
|
18 |
|
19 |
-
|
20 |
with gr.Blocks(fill_height=True) as demo:
|
21 |
history_var = gr.State([]) # conversation history
|
22 |
title = gr.Markdown(
|
@@ -36,6 +37,15 @@ with gr.Blocks(fill_height=True) as demo:
|
|
36 |
btn.click(generate, inputs=[prompt,language_selector,history_var], outputs=[history_var,output])
|
37 |
'''
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
with gr.Blocks(fill_height=True) as demo:
|
40 |
title = gr.Markdown(
|
41 |
"""
|
|
|
7 |
#iface = gr.load(name="Ghana-NLP/Khaya-chat-bot",hf_token=MY_HF_TOKEN_KEY,src ='spaces')
|
8 |
client = Client("Ghana-NLP/Khaya-chat-backend",hf_token=MY_HF_TOKEN_KEY)
|
9 |
|
10 |
+
'''
|
11 |
def generate(prompt,history,language):
|
12 |
history.append("USER: "+prompt+"\n-----\n")
|
13 |
output = client.predict(prompt,language)
|
|
|
17 |
full_output = full_output + el
|
18 |
return history,full_output
|
19 |
|
20 |
+
|
21 |
with gr.Blocks(fill_height=True) as demo:
|
22 |
history_var = gr.State([]) # conversation history
|
23 |
title = gr.Markdown(
|
|
|
37 |
btn.click(generate, inputs=[prompt,language_selector,history_var], outputs=[history_var,output])
|
38 |
'''
|
39 |
|
40 |
+
def generate(prompt,history,language):
|
41 |
+
history.append("USER: "+prompt+"\n-----\n")
|
42 |
+
output = client.predict(prompt,language)
|
43 |
+
history.append("KHAYA: "+output+"\n*****\n")
|
44 |
+
full_output = ""
|
45 |
+
for el in history:
|
46 |
+
full_output = full_output + el
|
47 |
+
return output
|
48 |
+
|
49 |
with gr.Blocks(fill_height=True) as demo:
|
50 |
title = gr.Markdown(
|
51 |
"""
|