Inan Ince
commited on
Commit
•
828d576
1
Parent(s):
6177bd2
Add application file5
Browse files- app.py +13 -3
- requirements.txt +1 -1
app.py
CHANGED
@@ -1,15 +1,25 @@
|
|
1 |
from transformers import pipeline, Conversation
|
2 |
import gradio as gr
|
3 |
|
|
|
|
|
|
|
|
|
4 |
message_list = []
|
5 |
response_list = []
|
6 |
|
7 |
def vanilla_chatbot(message, history):
|
|
|
8 |
conversation = Conversation(text=message, past_user_inputs=message_list, generated_responses=response_list)
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
12 |
|
|
|
13 |
demo_chatbot = gr.ChatInterface(vanilla_chatbot, title="Vanilla Chatbot", description="Enter text to start chatting.")
|
14 |
|
|
|
15 |
demo_chatbot.launch()
|
|
|
1 |
from transformers import pipeline, Conversation
|
2 |
import gradio as gr
|
3 |
|
4 |
+
# Chatbot modelini global olarak tanımlayın
|
5 |
+
chatbot_model = pipeline(model="facebook/blenderbot-400M-distill")
|
6 |
+
|
7 |
+
# Mesaj ve cevap listelerini global olarak tutun
|
8 |
message_list = []
|
9 |
response_list = []
|
10 |
|
11 |
def vanilla_chatbot(message, history):
|
12 |
+
# Conversation nesnesi oluşturun
|
13 |
conversation = Conversation(text=message, past_user_inputs=message_list, generated_responses=response_list)
|
14 |
+
# Chatbot modelini çağırarak yanıtı alın
|
15 |
+
response = chatbot_model(conversation)
|
16 |
+
# Yeni yanıtı global listeye ekleyin
|
17 |
+
message_list.append(message)
|
18 |
+
response_list.append(response.generated_responses[-1])
|
19 |
+
return response.generated_responses[-1]
|
20 |
|
21 |
+
# Gradio arayüzü oluşturun
|
22 |
demo_chatbot = gr.ChatInterface(vanilla_chatbot, title="Vanilla Chatbot", description="Enter text to start chatting.")
|
23 |
|
24 |
+
# Gradio uygulamasını başlatın
|
25 |
demo_chatbot.launch()
|
requirements.txt
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
gradio==3.39.0
|
2 |
transformers==4.31.0
|
3 |
-
torch==
|
|
|
1 |
gradio==3.39.0
|
2 |
transformers==4.31.0
|
3 |
+
torch==1.9.0
|