ikenna1234 commited on
Commit
4296f22
·
1 Parent(s): f509fd0
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -4,7 +4,8 @@ from huggingface_hub import InferenceClient
4
  """
5
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
  """
7
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
 
8
 
9
 
10
  def respond(
@@ -14,6 +15,7 @@ def respond(
14
  max_tokens,
15
  temperature,
16
  top_p,
 
17
  ):
18
  messages = [{"role": "system", "content": system_message}]
19
 
@@ -27,6 +29,8 @@ def respond(
27
 
28
  response = ""
29
 
 
 
30
  for message in client.chat_completion(
31
  messages,
32
  max_tokens=max_tokens,
@@ -46,7 +50,7 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
46
  demo = gr.ChatInterface(
47
  respond,
48
  additional_inputs=[
49
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
50
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
51
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
52
  gr.Slider(
@@ -56,6 +60,7 @@ demo = gr.ChatInterface(
56
  step=0.05,
57
  label="Top-p (nucleus sampling)",
58
  ),
 
59
  ],
60
  )
61
 
 
4
  """
5
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
  """
7
+ englishToFinnishClient = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
+ englishToSwedishClient = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
9
 
10
 
11
  def respond(
 
15
  max_tokens,
16
  temperature,
17
  top_p,
18
+ language
19
  ):
20
  messages = [{"role": "system", "content": system_message}]
21
 
 
29
 
30
  response = ""
31
 
32
+ client=englishToSwedishClient if(language=='english')else englishToSwedishClient
33
+
34
  for message in client.chat_completion(
35
  messages,
36
  max_tokens=max_tokens,
 
50
  demo = gr.ChatInterface(
51
  respond,
52
  additional_inputs=[
53
+ gr.Textbox(value="You are a language translator", label="System message"),
54
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
55
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
56
  gr.Slider(
 
60
  step=0.05,
61
  label="Top-p (nucleus sampling)",
62
  ),
63
+ gr.Textbox(value="english", label="Language"),
64
  ],
65
  )
66