Spaces:
Sleeping
Sleeping
added indictrans3 endpoint
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from nivra_agent import nivra_chat
|
|
|
|
| 3 |
|
| 4 |
|
| 5 |
def chat_fn(message, history):
|
|
@@ -22,6 +23,13 @@ def chat_fn(message, history):
|
|
| 22 |
|
| 23 |
# Return updated history + clear textbox
|
| 24 |
return history, ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
|
| 27 |
with gr.Blocks(title="🩺 Nivra AI Agent") as demo:
|
|
@@ -37,6 +45,20 @@ with gr.Blocks(title="🩺 Nivra AI Agent") as demo:
|
|
| 37 |
show_label=False,
|
| 38 |
)
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
with gr.Row():
|
| 41 |
txt = gr.Textbox(
|
| 42 |
placeholder="Describe your symptoms (e.g. fever, headache, chills)...",
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from nivra_agent import nivra_chat
|
| 3 |
+
from indicTrans3Infer import translate_text
|
| 4 |
|
| 5 |
|
| 6 |
def chat_fn(message, history):
|
|
|
|
| 23 |
|
| 24 |
# Return updated history + clear textbox
|
| 25 |
return history, ""
|
| 26 |
+
|
| 27 |
+
def indictrans_translate(text: str, target_language: str):
|
| 28 |
+
"""
|
| 29 |
+
Gradio-exposed translation endpoint
|
| 30 |
+
"""
|
| 31 |
+
translated = translate_text(text, target_language)
|
| 32 |
+
return translated
|
| 33 |
|
| 34 |
|
| 35 |
with gr.Blocks(title="🩺 Nivra AI Agent") as demo:
|
|
|
|
| 45 |
show_label=False,
|
| 46 |
)
|
| 47 |
|
| 48 |
+
# --- NEW: IndicTrans endpoint ---
|
| 49 |
+
translate_input = gr.Textbox(visible=False)
|
| 50 |
+
translate_lang = gr.Textbox(visible=False)
|
| 51 |
+
translate_output = gr.Textbox(visible=False)
|
| 52 |
+
|
| 53 |
+
translate_btn = gr.Button(visible=False)
|
| 54 |
+
|
| 55 |
+
translate_btn.click(
|
| 56 |
+
indictrans_translate,
|
| 57 |
+
inputs=[translate_input, translate_lang],
|
| 58 |
+
outputs=[translate_output],
|
| 59 |
+
api_name="indictrans_translate"
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
with gr.Row():
|
| 63 |
txt = gr.Textbox(
|
| 64 |
placeholder="Describe your symptoms (e.g. fever, headache, chills)...",
|