Yashvj123 commited on
Commit
0afd7df
Β·
verified Β·
1 Parent(s): 97ab694

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -5
app.py CHANGED
@@ -203,7 +203,7 @@ if uploaded_file:
203
  - Side Effects: ...
204
  - Special Instructions: ...
205
 
206
- Ensure each medicine starts with a new bullet point and all details are on separate lines.
207
  """
208
 
209
  prompt = PromptTemplate(input_variables=["prescription_text"], template=template)
@@ -263,10 +263,21 @@ if uploaded_file:
263
 
264
  if filtered_output and st.button("🌐 Translate to Hindi"):
265
  with st.spinner("Translating to Hindi..."):
266
- try:
267
- hindi_text = GoogleTranslator(source='en', target='hi').translate(filtered_output)
268
- except Exception as e:
269
- hindi_text = "[Error translating text]"
 
 
 
 
 
 
 
 
 
 
 
270
 
271
  st.markdown("#### 🌐 Hindi Translation")
272
  st.text_area("Translated Output (Hindi)", hindi_text, height=300)
 
203
  - Side Effects: ...
204
  - Special Instructions: ...
205
 
206
+ Ensure each medicine starts with a new bullet point and all details are on separate lines and don't bold any bullet point.
207
  """
208
 
209
  prompt = PromptTemplate(input_variables=["prescription_text"], template=template)
 
263
 
264
  if filtered_output and st.button("🌐 Translate to Hindi"):
265
  with st.spinner("Translating to Hindi..."):
266
+ hindi_text = GoogleTranslator(source='auto', target='hi').translate(filtered_output)
267
+
268
+
269
+ # API_URL = "https://api-inference.huggingface.co/models/facebook/mbart-large-50-many-to-many-mmt"
270
+ # headers = {"Authorization": f"Bearer YOUR_HF_TOKEN"}
271
+
272
+ # def translate_hi_to_fr(text):
273
+ # payload = {
274
+ # "inputs": f"hi_IN {text}", # manually prepending language code
275
+ # "parameters": {
276
+ # "forced_bos_token_id": 250012 # French
277
+ # }
278
+ # }
279
+ # response = requests.post(API_URL, headers=headers, json=payload)
280
+ # return response.json()
281
 
282
  st.markdown("#### 🌐 Hindi Translation")
283
  st.text_area("Translated Output (Hindi)", hindi_text, height=300)