ScriptMaster
commited on
Commit
·
554d956
1
Parent(s):
6c71ab4
Added pytorch
Browse files- app.py +30 -5
- requirements.txt +1 -0
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import pipeline
|
|
|
3 |
|
4 |
# def greet(name):
|
5 |
# return "Hello " + name + "!!"
|
@@ -11,14 +12,38 @@ chatbot_model = "facebook/blenderbot-400M-distill"
|
|
11 |
|
12 |
chatbot = pipeline(model=chatbot_model)
|
13 |
|
|
|
|
|
|
|
14 |
def echo(message, history):
|
15 |
return message
|
16 |
|
17 |
def chatbot_response(message, chat_history):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
chat_history.append(message)
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
-
app = gr.ChatInterface(fn=chatbot_response, examples=["
|
24 |
app.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline, Conversation
|
3 |
+
# from transformers.pipelines.conversational import Conversation
|
4 |
|
5 |
# def greet(name):
|
6 |
# return "Hello " + name + "!!"
|
|
|
12 |
|
13 |
chatbot = pipeline(model=chatbot_model)
|
14 |
|
15 |
+
past_user_inputs = []
|
16 |
+
generated_responses = []
|
17 |
+
|
18 |
def echo(message, history):
|
19 |
return message
|
20 |
|
21 |
def chatbot_response(message, chat_history):
|
22 |
+
# print(message)
|
23 |
+
# return message + "??" # message, chat_history
|
24 |
+
# conversation = Conversation(text=message, past_user_inputs=past_user_inputs, generated_responses=generated_responses)
|
25 |
+
# conv = Conversation(chat_history)
|
26 |
+
# conv = Conversation(text=message)
|
27 |
+
# print(chatbot)
|
28 |
+
# print("---")
|
29 |
+
# conv.add_user_input(message)
|
30 |
+
# print(conv)
|
31 |
+
# print("---")
|
32 |
chat_history.append(message)
|
33 |
+
# print(chat_history)
|
34 |
+
# print("---")
|
35 |
+
conv = chatbot(chat_history)
|
36 |
+
# generated_text = conv[-1]["generated_text"]
|
37 |
+
# print(generated_text)
|
38 |
+
return message + "??"
|
39 |
+
# return chat_history
|
40 |
+
# generated_text # , chat_history # , chat_history
|
41 |
+
# conv.append_response(bot_message)
|
42 |
+
|
43 |
+
# past_user_inputs.append(message)
|
44 |
+
# generated_responses.append(bot_message)
|
45 |
+
|
46 |
+
# chat_history.append((message, bot_message))
|
47 |
|
48 |
+
app = gr.ChatInterface(fn=chatbot_response, examples=["hi", "hola", "merhaba"], title="Chat Bot")
|
49 |
app.launch()
|
requirements.txt
CHANGED
@@ -1 +1,2 @@
|
|
1 |
transformers
|
|
|
|
1 |
transformers
|
2 |
+
pytorch
|