Spaces:
Runtime error
Runtime error
Update TabsTask.py
Browse files- TabsTask.py +24 -4
TabsTask.py
CHANGED
|
@@ -77,6 +77,20 @@ def chatbot(message, chat_history):
|
|
| 77 |
|
| 78 |
return bot_reply
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
# === Build Gradio Interface ===
|
| 81 |
with gr.Blocks() as demo:
|
| 82 |
with gr.Tab("Sentiment Analysis"):
|
|
@@ -101,9 +115,15 @@ with gr.Blocks() as demo:
|
|
| 101 |
tts_button.click(text_to_speech, inputs=tts_input, outputs=tts_output)
|
| 102 |
|
| 103 |
with gr.ChatInterface(
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
)
|
| 109 |
demo.launch()
|
|
|
|
| 77 |
|
| 78 |
return bot_reply
|
| 79 |
|
| 80 |
+
chat_pipeline1 = pipeline("text-generation", model="yasserrmd/Human-Like-Qwen2.5-1.5B-Instruct")
|
| 81 |
+
|
| 82 |
+
# === Chatbot ===
|
| 83 |
+
def chatbot(message, chat_history):
|
| 84 |
+
# Generate response
|
| 85 |
+
result = chat_pipeline1(message, max_new_tokens=10)
|
| 86 |
+
|
| 87 |
+
# Extract only the reply
|
| 88 |
+
bot_reply = result[0]["generated_text"]
|
| 89 |
+
|
| 90 |
+
return bot_reply
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
|
| 94 |
# === Build Gradio Interface ===
|
| 95 |
with gr.Blocks() as demo:
|
| 96 |
with gr.Tab("Sentiment Analysis"):
|
|
|
|
| 115 |
tts_button.click(text_to_speech, inputs=tts_input, outputs=tts_output)
|
| 116 |
|
| 117 |
with gr.ChatInterface(
|
| 118 |
+
chatbot,
|
| 119 |
+
type="messages",
|
| 120 |
+
title="Chatbot",
|
| 121 |
+
description="Start the conversation by sending text messages or ask questions!",
|
| 122 |
+
)
|
| 123 |
+
with gr.ChatInterface(
|
| 124 |
+
chatbot,
|
| 125 |
+
type="messages",
|
| 126 |
+
title="Chatbot",
|
| 127 |
+
description="Start the conversation by sending text messages or ask questions!",
|
| 128 |
)
|
| 129 |
demo.launch()
|