Ashrafb commited on
Commit
30c9cd0
1 Parent(s): 51c4a10

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
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
- options = {"src": "ar", "tgt": "en"}
94
- options.update({"timestamp": timestamp})
95
-
96
- # Adjust this line if needed based on the model's input/output specifications
97
- return text_gen(prompt_text, options=options)
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...