Robert Pardela
commited on
Commit
·
72bd82a
1
Parent(s):
0d64bfc
time
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
from transformers import pipeline, Conversation
|
2 |
import gradio as gr
|
|
|
3 |
|
4 |
chatbot = pipeline("text-generation", model="epfl-llm/meditron-7b", use_auth_token=True)
|
5 |
# chatbot = pipeline("translation", model="facebook/mbart-large-50-many-to-many-mmt", use_auth_token=True)
|
@@ -8,10 +9,13 @@ message_list = []
|
|
8 |
response_list = []
|
9 |
|
10 |
def vanilla_chatbot(message, history):
|
|
|
11 |
conversation = Conversation(text=message, past_user_inputs=message_list, generated_responses=response_list)
|
12 |
conversation = chatbot(conversation)
|
13 |
-
|
14 |
-
|
|
|
|
|
15 |
|
16 |
def chat_bot(message, history):
|
17 |
return chatbot(message, max_length=500)[0]['generated_text']
|
|
|
1 |
from transformers import pipeline, Conversation
|
2 |
import gradio as gr
|
3 |
+
import time
|
4 |
|
5 |
chatbot = pipeline("text-generation", model="epfl-llm/meditron-7b", use_auth_token=True)
|
6 |
# chatbot = pipeline("translation", model="facebook/mbart-large-50-many-to-many-mmt", use_auth_token=True)
|
|
|
9 |
response_list = []
|
10 |
|
11 |
def vanilla_chatbot(message, history):
|
12 |
+
start = time.perf_counter()
|
13 |
conversation = Conversation(text=message, past_user_inputs=message_list, generated_responses=response_list)
|
14 |
conversation = chatbot(conversation)
|
15 |
+
to_return = conversation.generated_responses[-1]
|
16 |
+
|
17 |
+
print ("%5.1f secs " % (start - time.perf_counter()))
|
18 |
+
return to_return
|
19 |
|
20 |
def chat_bot(message, history):
|
21 |
return chatbot(message, max_length=500)[0]['generated_text']
|