ikenna1234 commited on
Commit
d6456b2
·
1 Parent(s): 6f43c03
Files changed (1) hide show
  1. app.py +32 -5
app.py CHANGED
@@ -17,7 +17,8 @@ def respond(
17
  temperature,
18
  top_p,
19
  sourceLanguage,
20
- targetLanguage
 
21
  ):
22
  toFinnish=targetLanguage=='Finnish' and sourceLanguage=="English"
23
  fromFinnish=targetLanguage=='English' and sourceLanguage=="Finnish"
@@ -27,11 +28,36 @@ def respond(
27
  #candidateClient=finnishToEnglishClient if(fromFinnish)else googleClient
28
 
29
  print("the text",message, 'the source',sourceLanguage,"the target",targetLanguage)
30
-
31
- response=''
32
-
 
 
 
33
 
 
 
34
  if(toFinnish):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  fiResponse= englishToFinnishClient.translation(
36
  message,
37
  #max_new_tokens=100
@@ -68,7 +94,7 @@ def respond(
68
 
69
  print("the response",response)
70
 
71
- response
72
 
73
 
74
  """
@@ -89,6 +115,7 @@ demo = gr.ChatInterface(
89
  ),
90
  gr.Textbox(value="Finnish", label="Source Language"),
91
  gr.Textbox(value="English", label="Target Language"),
 
92
  ],
93
  )
94
 
 
17
  temperature,
18
  top_p,
19
  sourceLanguage,
20
+ targetLanguage,
21
+ useGoogle
22
  ):
23
  toFinnish=targetLanguage=='Finnish' and sourceLanguage=="English"
24
  fromFinnish=targetLanguage=='English' and sourceLanguage=="Finnish"
 
28
  #candidateClient=finnishToEnglishClient if(fromFinnish)else googleClient
29
 
30
  print("the text",message, 'the source',sourceLanguage,"the target",targetLanguage)
31
+
32
+ if(useGoogle):
33
+ text="Translate to "f"{targetLanguage}: "f"{message}"
34
+ googleResponse= googleClient.text_generation(
35
+ text
36
+ )
37
 
38
+ return googleResponse
39
+
40
  if(toFinnish):
41
+ fiResponse= englishToFinnishClient.translation(
42
+ message,
43
+ #max_new_tokens=100
44
+ tgt_lang= targetLanguage,
45
+ src_lang=sourceLanguage
46
+ )
47
+
48
+ return fiResponse.translation_text
49
+
50
+ if(fromFinnish):
51
+ fiResponse=finnishToEnglishClient.translation(
52
+ message,
53
+ tgt_lang= targetLanguage,
54
+ src_lang=sourceLanguage
55
+ )
56
+
57
+ return fiResponse.translation_text
58
+
59
+
60
+ """ if(toFinnish):
61
  fiResponse= englishToFinnishClient.translation(
62
  message,
63
  #max_new_tokens=100
 
94
 
95
  print("the response",response)
96
 
97
+ response """
98
 
99
 
100
  """
 
115
  ),
116
  gr.Textbox(value="Finnish", label="Source Language"),
117
  gr.Textbox(value="English", label="Target Language"),
118
+ gr.Textbox(value="false", label="Use Google"),
119
  ],
120
  )
121