Roseco-crs
commited on
Commit
·
6b3dc32
1
Parent(s):
7a1757b
Another update to fix deployment challenge occurs on Huggingface
Browse files- app.py +56 -52
- pyproject.toml +2 -0
- requirements.txt +3 -1
app.py
CHANGED
|
@@ -2,56 +2,60 @@ from ailab_crs import NLP_tasks_crs, Prompt_engineering_crs
|
|
| 2 |
import gradio as gr
|
| 3 |
from googletrans import LANGUAGES
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
with gr.
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
with gr.
|
| 16 |
-
with gr.
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
with gr.
|
| 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 |
if __name__ == "__main__":
|
| 57 |
-
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from googletrans import LANGUAGES
|
| 4 |
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def main():
|
| 8 |
+
|
| 9 |
+
nlp_tasks = NLP_tasks_crs()
|
| 10 |
+
supported_langs = list(LANGUAGES.values())
|
| 11 |
+
|
| 12 |
+
with gr.Blocks() as demo:
|
| 13 |
+
gr.Markdown("# 🧠 NaanAI 💡")
|
| 14 |
+
|
| 15 |
+
with gr.Row():
|
| 16 |
+
with gr.Column():
|
| 17 |
+
text = gr.Textbox(label="Your Query", lines=8)
|
| 18 |
+
with gr.Column():
|
| 19 |
+
with gr.Accordion("Other Parameters (For Translation or Summarization Tasks)", open= True):
|
| 20 |
+
# language = gr.Textbox(label="Language")
|
| 21 |
+
language = gr.Dropdown(choices=supported_langs, label="Select Target Language", value="english")
|
| 22 |
+
style = gr.Textbox(label="Choose Your Style", value="polite")
|
| 23 |
+
|
| 24 |
+
with gr.Row(scale=5):
|
| 25 |
+
with gr.Column(scale=1, min_width=1):
|
| 26 |
+
btn = gr.Button("Q&A")
|
| 27 |
+
with gr.Column(scale=2, min_width=1):
|
| 28 |
+
btn1 = gr.Button("Translator")
|
| 29 |
+
with gr.Column(scale=2, min_width=1):
|
| 30 |
+
btn2 = gr.Button("Summarizer")
|
| 31 |
+
with gr.Column(scale=2, min_width=1):
|
| 32 |
+
btn3 = gr.Button("Translator_Summarizer")
|
| 33 |
+
|
| 34 |
+
answer = gr.Textbox(label="AI Answer", lines=2)
|
| 35 |
+
|
| 36 |
+
btn.click(
|
| 37 |
+
fn= nlp_tasks.question_answer,
|
| 38 |
+
inputs= text,
|
| 39 |
+
outputs=answer
|
| 40 |
+
)
|
| 41 |
+
btn1.click(
|
| 42 |
+
fn= nlp_tasks.translator,
|
| 43 |
+
inputs= [text, language, style],
|
| 44 |
+
outputs=answer
|
| 45 |
+
)
|
| 46 |
+
btn2.click(
|
| 47 |
+
fn= nlp_tasks.summarization,
|
| 48 |
+
inputs= text,
|
| 49 |
+
outputs=answer
|
| 50 |
+
)
|
| 51 |
+
btn3.click(
|
| 52 |
+
fn= nlp_tasks.translator_summarization,
|
| 53 |
+
inputs= [text, language, style],
|
| 54 |
+
outputs=answer
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
return demo.launch()
|
| 58 |
+
|
| 59 |
+
|
| 60 |
if __name__ == "__main__":
|
| 61 |
+
main()
|
pyproject.toml
CHANGED
|
@@ -5,10 +5,12 @@ description = "Add your description here"
|
|
| 5 |
readme = "README.md"
|
| 6 |
requires-python = ">=3.10"
|
| 7 |
dependencies = [
|
|
|
|
| 8 |
"googletrans>=4.0.2",
|
| 9 |
"gradio[mcp]>=6.0.1",
|
| 10 |
"langchain>=1.1.0",
|
| 11 |
"langchain-core>=1.1.0",
|
| 12 |
"langchain-groq>=1.1.0",
|
| 13 |
"python-dotenv>=1.2.1",
|
|
|
|
| 14 |
]
|
|
|
|
| 5 |
readme = "README.md"
|
| 6 |
requires-python = ">=3.10"
|
| 7 |
dependencies = [
|
| 8 |
+
"aiohttp>=3.13.2",
|
| 9 |
"googletrans>=4.0.2",
|
| 10 |
"gradio[mcp]>=6.0.1",
|
| 11 |
"langchain>=1.1.0",
|
| 12 |
"langchain-core>=1.1.0",
|
| 13 |
"langchain-groq>=1.1.0",
|
| 14 |
"python-dotenv>=1.2.1",
|
| 15 |
+
"requests>=2.32.5",
|
| 16 |
]
|
requirements.txt
CHANGED
|
@@ -4,4 +4,6 @@ python-dotenv
|
|
| 4 |
langchain
|
| 5 |
langchain-core
|
| 6 |
googletrans
|
| 7 |
-
gradio[mcp]
|
|
|
|
|
|
|
|
|
| 4 |
langchain
|
| 5 |
langchain-core
|
| 6 |
googletrans
|
| 7 |
+
gradio[mcp]
|
| 8 |
+
requests
|
| 9 |
+
aiohttp
|