Roseco-crs commited on
Commit
6b3dc32
·
1 Parent(s): 7a1757b

Another update to fix deployment challenge occurs on Huggingface

Browse files
Files changed (3) hide show
  1. app.py +56 -52
  2. pyproject.toml +2 -0
  3. 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
- supported_langs = list(LANGUAGES.values())
6
- nlp_tasks = NLP_tasks_crs() # Instantiate your NLP tasks
7
-
8
- # Define Gradio app at the global level
9
- with gr.Blocks() as demo:
10
- gr.Markdown("# 🧠NaanhAI💡")
11
-
12
- with gr.Row():
13
- with gr.Column():
14
- text = gr.Textbox(label="Your Query", lines=8)
15
- with gr.Column():
16
- with gr.Accordion("Other Parameters For Translation or Summarization Tasks", open=True):
17
- language = gr.Dropdown(choices=supported_langs, label="Select Target Language", value="english")
18
- style = gr.Textbox(label="Choose Your Style", value="polite")
19
- # Alternatively: style = gr.Dropdown(choices=["polite", "sad", "happy", "scientific", "religious"], value="polite")
20
-
21
- with gr.Row(scale=5):
22
- with gr.Column(scale=1, min_width=1):
23
- btn = gr.Button("Q&A")
24
- with gr.Column(scale=2, min_width=1):
25
- btn1 = gr.Button("Translator")
26
- with gr.Column(scale=2, min_width=1):
27
- btn2 = gr.Button("Summarizer")
28
- with gr.Column(scale=2, min_width=1):
29
- btn3 = gr.Button("Translator_Summarizer")
30
-
31
- answer = gr.Textbox(label="AI Answer", lines=2)
32
-
33
- # Connect buttons to functions
34
- btn.click(
35
- fn=nlp_tasks.question_answer,
36
- inputs=text,
37
- outputs=answer
38
- )
39
- btn1.click(
40
- fn=nlp_tasks.translator,
41
- inputs=[text, language, style],
42
- outputs=answer
43
- )
44
- btn2.click(
45
- fn=nlp_tasks.summarization,
46
- inputs=text,
47
- outputs=answer
48
- )
49
- btn3.click(
50
- fn=nlp_tasks.translator_summarization,
51
- inputs=[text, language, style],
52
- outputs=answer
53
- )
54
-
55
- # Optional local launch
 
 
 
 
56
  if __name__ == "__main__":
57
- demo.launch(share = True)
 
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