Spaces:
Sleeping
Sleeping
deniandriancode
commited on
Commit
·
40a6fd6
1
Parent(s):
3bc2b07
initial commit
Browse files- app.py +22 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline, Conversation
|
3 |
+
|
4 |
+
chatbot = pipeline("conversational", model="facebook/blenderbot-400M-distill")
|
5 |
+
|
6 |
+
converse = None
|
7 |
+
|
8 |
+
def model_generate(text, state = None):
|
9 |
+
if state == None:
|
10 |
+
converse = Conversation(text)
|
11 |
+
else:
|
12 |
+
converse.add_user_input(text)
|
13 |
+
|
14 |
+
converse = chatbot(converse)
|
15 |
+
return converse.generated_responses[-1]
|
16 |
+
|
17 |
+
def get_response(text, history) -> str:
|
18 |
+
output = model_generate(text, converse)
|
19 |
+
return output
|
20 |
+
|
21 |
+
interface = gr.ChatInterface(get_response)
|
22 |
+
interface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
transformers
|