azunre commited on
Commit
8893347
1 Parent(s): b94f08a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -7,26 +7,29 @@ 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-bot",hf_token=MY_HF_TOKEN_KEY)
9
 
 
 
10
  def generate(prompt,language):
11
  output = client.predict(prompt,language)
12
- return output
 
13
 
14
  with gr.Blocks() as demo:
15
  title = gr.Markdown(
16
  """
17
  # African Language Chatbot (Khaya)
18
- SELECT YOUR LANGUAGE BELOW!
 
 
19
  Based on the <a href="https://translation.ghananlp.org/">Khaya AI Translation API</a>, <a href="https://lesan.ai/">Lesan AI</a>, Google Translate API and the Mixtral model. Lesan is used for <b>Amharic</b> and <b>Tigrinya</b>, <a href="https://translation.ghananlp.org/">Khaya AI</a> is used for <b>Twi</b>, <b>Dagbani</b>, <b>Ewe</b>, <b>Ga</b>, <b>Gurene</b>, <b>Fante</b>, <b>Kikuyu</b>, <b>Kimeru</b>, <b>Luo</b>, <b>Yoruba</b> and Google is used for <b>Hausa</b>, <b>Swahili</b> and <b>Shona</b>.
20
  """)
21
  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:")
22
- history = ""
23
  with gr.Row():
24
  output = gr.Text(label="Conversation:")
25
- history = history + "\n" + output
26
  with gr.Row():
27
  prompt = gr.Text(label="Enter Text In Your Local Language:")
28
  btn = gr.Button("Chat")
29
- btn.click(generate, inputs=[prompt,language_selector], outputs=[history])
30
 
31
  if __name__ == "__main__":
32
  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-bot",hf_token=MY_HF_TOKEN_KEY)
9
 
10
+ history = "" # history string
11
+
12
  def generate(prompt,language):
13
  output = client.predict(prompt,language)
14
+ history = history + "\n" + output
15
+ return history
16
 
17
  with gr.Blocks() as demo:
18
  title = gr.Markdown(
19
  """
20
  # African Language Chatbot (Khaya)
21
+ 1. SELECT YOUR LANGUAGE
22
+ 2. TYPE IN SELECTED LANGUAGE!!
23
+ 3. REFRESH PAGE TO START FRESH CONVERSATION
24
  Based on the <a href="https://translation.ghananlp.org/">Khaya AI Translation API</a>, <a href="https://lesan.ai/">Lesan AI</a>, Google Translate API and the Mixtral model. Lesan is used for <b>Amharic</b> and <b>Tigrinya</b>, <a href="https://translation.ghananlp.org/">Khaya AI</a> is used for <b>Twi</b>, <b>Dagbani</b>, <b>Ewe</b>, <b>Ga</b>, <b>Gurene</b>, <b>Fante</b>, <b>Kikuyu</b>, <b>Kimeru</b>, <b>Luo</b>, <b>Yoruba</b> and Google is used for <b>Hausa</b>, <b>Swahili</b> and <b>Shona</b>.
25
  """)
26
  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:")
 
27
  with gr.Row():
28
  output = gr.Text(label="Conversation:")
 
29
  with gr.Row():
30
  prompt = gr.Text(label="Enter Text In Your Local Language:")
31
  btn = gr.Button("Chat")
32
+ btn.click(generate, inputs=[prompt,language_selector], outputs=[output])
33
 
34
  if __name__ == "__main__":
35
  demo.queue(max_size=20).launch()