Spaces:
Runtime error
Runtime error
Update TabsTask.py
Browse files- TabsTask.py +40 -35
TabsTask.py
CHANGED
|
@@ -80,7 +80,7 @@ def chatbot(message, chat_history):
|
|
| 80 |
chat_pipeline1 = pipeline("text-generation", model="yasserrmd/Human-Like-Qwen2.5-1.5B-Instruct")
|
| 81 |
|
| 82 |
# === Chatbot ===
|
| 83 |
-
def
|
| 84 |
# Generate response
|
| 85 |
result = chat_pipeline1(message, max_new_tokens=10)
|
| 86 |
|
|
@@ -90,40 +90,45 @@ def chatbot(message, chat_history):
|
|
| 90 |
return bot_reply
|
| 91 |
|
| 92 |
|
| 93 |
-
|
| 94 |
# === Build Gradio Interface ===
|
| 95 |
with gr.Blocks() as demo:
|
| 96 |
-
with gr.
|
| 97 |
-
gr.
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
gr.
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
gr.
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
demo.launch()
|
|
|
|
| 80 |
chat_pipeline1 = pipeline("text-generation", model="yasserrmd/Human-Like-Qwen2.5-1.5B-Instruct")
|
| 81 |
|
| 82 |
# === Chatbot ===
|
| 83 |
+
def chatbot1(message, chat_history):
|
| 84 |
# Generate response
|
| 85 |
result = chat_pipeline1(message, max_new_tokens=10)
|
| 86 |
|
|
|
|
| 90 |
return bot_reply
|
| 91 |
|
| 92 |
|
|
|
|
| 93 |
# === Build Gradio Interface ===
|
| 94 |
with gr.Blocks() as demo:
|
| 95 |
+
with gr.Tabs():
|
| 96 |
+
with gr.Tab("Sentiment Analysis"):
|
| 97 |
+
gr.Markdown("### 🔍 Sentiment Analysis")
|
| 98 |
+
sentiment_input = gr.Textbox(label="Enter text", lines=3, placeholder="Type a sentence to analyze...")
|
| 99 |
+
sentiment_button = gr.Button("Analyze")
|
| 100 |
+
sentiment_output = gr.Textbox(label="Sentiment")
|
| 101 |
+
sentiment_button.click(analyze_sentiment, inputs=sentiment_input, outputs=sentiment_output)
|
| 102 |
+
|
| 103 |
+
with gr.Tab("Summarization"):
|
| 104 |
+
gr.Markdown("### ✂️ Summarization")
|
| 105 |
+
summary_input = gr.Textbox(label="Enter text", lines=8, placeholder="Paste long text here...")
|
| 106 |
+
summary_button = gr.Button("Summarize")
|
| 107 |
+
summary_output = gr.Textbox(label="Summary")
|
| 108 |
+
summary_button.click(summarize_text, inputs=summary_input, outputs=summary_output)
|
| 109 |
+
|
| 110 |
+
with gr.Tab("Text-to-Speech"):
|
| 111 |
+
gr.Markdown("### 🗣️ Text-to-Speech (using Bark)")
|
| 112 |
+
tts_input = gr.Textbox(label="Enter text to speak", lines=3, placeholder="Try something like: 'Hello, how are you?'")
|
| 113 |
+
tts_button = gr.Button("Generate Speech")
|
| 114 |
+
tts_output = gr.Audio(label="Generated Speech", type="numpy")
|
| 115 |
+
tts_button.click(text_to_speech, inputs=tts_input, outputs=tts_output)
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
with gr.TabItem("Chatbot 1"):
|
| 119 |
+
gr.ChatInterface(
|
| 120 |
+
chatbot,
|
| 121 |
+
type="messages",
|
| 122 |
+
title="Chatbot 1",
|
| 123 |
+
description="Start the conversation in Chatbot 1!")
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
with gr.TabItem("Chatbot 2"):
|
| 127 |
+
gr.ChatInterface(
|
| 128 |
+
chatbot1,
|
| 129 |
+
type="messages",
|
| 130 |
+
title="Chatbot 2",
|
| 131 |
+
description="Start the conversation in Chatbot 2!")
|
| 132 |
+
|
| 133 |
+
|
| 134 |
demo.launch()
|