JustKiddo commited on
Commit
d6e0873
·
verified ·
1 Parent(s): 88ad874

Reversed back to the last-known good code.

Browse files
Files changed (1) hide show
  1. app.py +7 -12
app.py CHANGED
@@ -1,18 +1,15 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
 
3
  from datasets import load_dataset
4
 
 
 
 
5
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
6
  dataset = load_dataset("JustKiddo/KiddosVault")
 
7
 
8
- ## A translation dataset for Vietnamese responses ##
9
- translation = load_dataset("mt_eng_vietnamese")
10
- trust_remote_code=True ## Trust remote code ##
11
-
12
- def translate_text(text, translation_dataset):
13
- # Assuming the translation dataset has a method to translate text
14
- translated_text = translation_dataset['train'][0]['translation']['vi'] # Example translation
15
- return translated_text
16
 
17
  def respond(
18
  message,
@@ -42,16 +39,13 @@ def respond(
42
  top_p=top_p,
43
  ):
44
  token = message.choices[0].delta.content
 
45
  response += token
46
  yield response
47
 
48
- translated_response = translate_text(response, translation)
49
- yield response + "\n\nTranslation: " + translated_response
50
-
51
  """
52
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
53
  """
54
-
55
  demo = gr.ChatInterface(
56
  respond,
57
  additional_inputs=[
@@ -68,5 +62,6 @@ demo = gr.ChatInterface(
68
  ],
69
  )
70
 
 
71
  if __name__ == "__main__":
72
  demo.launch()
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
+
4
  from datasets import load_dataset
5
 
6
+ """
7
+ 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
8
+ """
9
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
10
  dataset = load_dataset("JustKiddo/KiddosVault")
11
+ translation = load_dataset("IWSLT/mt_eng_vietnamese")
12
 
 
 
 
 
 
 
 
 
13
 
14
  def respond(
15
  message,
 
39
  top_p=top_p,
40
  ):
41
  token = message.choices[0].delta.content
42
+
43
  response += token
44
  yield response
45
 
 
 
 
46
  """
47
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
48
  """
 
49
  demo = gr.ChatInterface(
50
  respond,
51
  additional_inputs=[
 
62
  ],
63
  )
64
 
65
+
66
  if __name__ == "__main__":
67
  demo.launch()