File size: 2,209 Bytes
acfcb6f ec58da7 592c318 ec58da7 f9447c2 592c318 ec58da7 306b3d4 592c318 f9447c2 592c318 306b3d4 f9447c2 6b3dc32 f9447c2 ec58da7 f9447c2 6b3dc32 acfcb6f 306b3d4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
from ailab_crs import NLP_tasks_crs, Prompt_engineering_crs
import gradio as gr
from googletrans import LANGUAGES
# CSS to hide the entire footer, including "Made with Gradio", settings, and API info
hide_footer_css = """
<style>
footer, footer * {
display: none !important;
}
</style>
"""
# Mobile-friendly CSS
mobile_css = """
<style>
/* Make all inputs, textboxes, and buttons full width on small screens */
@media (max-width: 768px) {
input, textarea, button, .gr-textbox, .gr-button {
width: 100% !important;
margin: 5px 0 !important;
}
}
</style>
"""
nlp_tasks = NLP_tasks_crs()
supported_langs = list(LANGUAGES.values())
with gr.Blocks() as demo:
# Inject the mobile CSS
gr.HTML(mobile_css)
# App title
gr.Markdown("# 🧠 NaanhAI 💡")
# Inject the CSS at the top
gr.HTML(hide_footer_css)
with gr.Row():
with gr.Column():
text = gr.Textbox(label="Your Query", lines=8)
with gr.Column():
with gr.Accordion("Translation & Summarization Parameters ", open= True):
language = gr.Dropdown(choices=supported_langs, label="Select Target Language", value="french")
style = gr.Textbox(label="Choose Your Style", 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
)
if __name__ == "__main__":
demo.launch() |