Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +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,language
|
11 |
history.append("USER: "+prompt+"\n-----\n")
|
12 |
output = client.predict(prompt,language)
|
13 |
history.append("KHAYA: "+output+"\n*****\n")
|
@@ -16,6 +16,7 @@ def generate(prompt,language,history):
|
|
16 |
full_output = full_output + el
|
17 |
return history,full_output
|
18 |
|
|
|
19 |
with gr.Blocks(fill_height=True) as demo:
|
20 |
history_var = gr.State([]) # conversation history
|
21 |
title = gr.Markdown(
|
@@ -33,6 +34,19 @@ with gr.Blocks(fill_height=True) as demo:
|
|
33 |
prompt = gr.Text(label="Enter Text In Your Local Language:")
|
34 |
btn = gr.Button("Chat")
|
35 |
btn.click(generate, inputs=[prompt,language_selector,history_var], outputs=[history_var,output])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
if __name__ == "__main__":
|
38 |
demo.queue(max_size=20).launch()
|
|
|
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)
|
13 |
history.append("KHAYA: "+output+"\n*****\n")
|
|
|
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(
|
|
|
34 |
prompt = gr.Text(label="Enter Text In Your Local Language:")
|
35 |
btn = gr.Button("Chat")
|
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 |
+
"""
|
42 |
+
# African Language Chatbot (Khaya)
|
43 |
+
SELECT YOUR LANGUAGE BELOW!
|
44 |
+
""")
|
45 |
+
language_selector = gr.Dropdown(["Amharic","Twi","Dagbani","Ewe","Ga","Gurene","Fante","Hausa", "Kikuyu", "Kimeru", "Luo","Shona","Swahili","Tigrinya","Yoruba"],value="Twi",label="Choose Language! (default is Twi)", info="Language:")
|
46 |
+
main_block = gr.ChatInterface(fn=generate, additional_inputs = language_selector,
|
47 |
+
description = 'Select an African language above and type messages below in selected language',
|
48 |
+
retry_btn=None,
|
49 |
+
undo_btn=None)
|
50 |
|
51 |
if __name__ == "__main__":
|
52 |
demo.queue(max_size=20).launch()
|