azunre commited on
Commit
a31bb41
·
verified ·
1 Parent(s): 129570f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -32
app.py CHANGED
@@ -4,39 +4,8 @@ from gradio_client import Client
4
 
5
  MY_HF_TOKEN_KEY = os.environ["MY_HF_TOKEN_KEY"]
6
 
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)
14
- history.append("KHAYA: "+output+"\n*****\n")
15
- full_output = ""
16
- for el in history:
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(
24
- """
25
- # African Language Chatbot (Khaya)
26
- 1. SELECT YOUR LANGUAGE
27
- 2. TYPE IN SELECTED LANGUAGE!!
28
- 3. REFRESH PAGE TO START FRESH CONVERSATION \n\n
29
- 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>.
30
- """)
31
- 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:")
32
- with gr.Row():
33
- output = gr.Text(label="OUTPUT WINDOW (Conversation so far):")
34
- with gr.Row():
35
- prompt = gr.Text(label="Enter Text In Your Local Language:")
36
- btn = gr.Button("Chat")
37
- btn.click(generate, inputs=[prompt,language_selector,history_var], outputs=[history_var,output])
38
- '''
39
-
40
  def generate(prompt,history,language):
41
  print(history)
42
  output = client.predict(prompt,language)
@@ -49,8 +18,8 @@ with gr.Blocks(fill_height=True) as demo:
49
  """
50
  # African Language Chatbot (Khaya)
51
  SELECT YOUR LANGUAGE BELOW!
 
52
  """)
53
- #history_var = gr.State([]) # conversation history
54
  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:")
55
  main_block = gr.ChatInterface(fn=generate, additional_inputs = language_selector,
56
  description = 'Select an African language above and type messages below in selected language')
 
4
 
5
  MY_HF_TOKEN_KEY = os.environ["MY_HF_TOKEN_KEY"]
6
 
 
7
  client = Client("Ghana-NLP/Khaya-chat-backend",hf_token=MY_HF_TOKEN_KEY)
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  def generate(prompt,history,language):
10
  print(history)
11
  output = client.predict(prompt,language)
 
18
  """
19
  # African Language Chatbot (Khaya)
20
  SELECT YOUR LANGUAGE BELOW!
21
+ Based on the <a href="https://translation.ghananlp.org/">Khaya AI Translation API</a> and <a href="https://lesan.ai/">Lesan AI</a>. Lesan is used for <b>Amharic</b> and <b>Tigrinya</b>, Khaya is used for the rest.
22
  """)
 
23
  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:")
24
  main_block = gr.ChatInterface(fn=generate, additional_inputs = language_selector,
25
  description = 'Select an African language above and type messages below in selected language')