NaanhAI / app.py
Roseco-crs
NaanhAI project using Gradio as interface.
acfcb6f
raw
history blame
2.01 kB
from ailab_crs import NLP_tasks_crs, Prompt_engineering_crs
import gradio as gr
from googletrans import LANGUAGES
supported_langs = list(LANGUAGES.values())
def main():
nlp_tasks = NLP_tasks_crs()
with gr.Blocks() as demo:
gr.Markdown("# 🧠NaanhAI💡")
with gr.Row():
with gr.Column():
text = gr.Textbox(label="Your Query", lines=8)
with gr.Column():
with gr.Accordion("Other Parameters For Translation or Summarization Tasks", open= True):
language = gr.Dropdown(choices=supported_langs, label="Select Target Language", value="english")
style = gr.Textbox(label="Choose Your Style", value = "polite")
# style = gr.Dropdown(choices= ["polite", "sad", "happy", "scientific", "religious"], value= "polite")
with gr.Row(scale=5):
with gr.Column(scale=1, min_width=1):
btn = gr.Button("Q&A")
with gr.Column(scale=2, min_width=1):
btn1 = gr.Button("Translator")
with gr.Column(scale=2, min_width=1):
btn2 = gr.Button("Summarizer")
with gr.Column(scale=2, min_width=1):
btn3 = gr.Button("Translator_Summarizer")
answer = gr.Textbox(label="AI Answer", lines=2)
btn.click(
fn= nlp_tasks.question_answer,
inputs= text,
outputs=answer
)
btn1.click(
fn= nlp_tasks.translator,
inputs= [text, language, style],
outputs=answer
)
btn2.click(
fn= nlp_tasks.summarization,
inputs= text,
outputs=answer
)
btn3.click(
fn= nlp_tasks.translator_summarization,
inputs= [text, language, style],
outputs=answer
)
demo.launch(share=True)
# demo.launch(mcp_server=True)
if __name__ == "__main__":
main()