Update app.py
Browse files
app.py
CHANGED
@@ -83,19 +83,18 @@ import time
|
|
83 |
|
84 |
def get_prompts(prompt_text):
|
85 |
if not prompt_text:
|
86 |
-
return "Please enter text before generating prompts.رجاء ادخل النص اولا"
|
87 |
-
raise gr.Error("Please enter text before generating prompts.رجاء ادخل النص اولا")
|
88 |
else:
|
89 |
global request_counter
|
90 |
request_counter += 1
|
91 |
timestamp = f"{time.time()}_{request_counter}"
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
|
100 |
|
101 |
# Existing code...
|
|
|
83 |
|
84 |
def get_prompts(prompt_text):
|
85 |
if not prompt_text:
|
86 |
+
return "Please enter text before generating prompts.رجاء ادخل النص اولا"
|
|
|
87 |
else:
|
88 |
global request_counter
|
89 |
request_counter += 1
|
90 |
timestamp = f"{time.time()}_{request_counter}"
|
91 |
|
92 |
+
tokenizer.src_lang = "ar_AR"
|
93 |
+
encoded_ar = tokenizer(prompt_text, return_tensors="pt")
|
94 |
+
generated_tokens = model.generate(**encoded_ar)
|
95 |
+
translated_text = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)[0]
|
96 |
+
|
97 |
+
return translated_text
|
98 |
|
99 |
|
100 |
# Existing code...
|