Updated app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
|
|
2 |
from transformers import Conversation, pipeline
|
3 |
from typing import Union
|
4 |
|
5 |
-
chatbot = pipeline(model="facebook/blenderbot-400M-distill")
|
6 |
|
7 |
def process(prompt:Union[str,None]=None,history:Union[str,None]=None):
|
8 |
"""" process prompt
|
@@ -27,15 +27,12 @@ def process(prompt:Union[str,None]=None,history:Union[str,None]=None):
|
|
27 |
prompt = gr.Textbox(label="Prompt")
|
28 |
history = gr.Textbox(label="History")
|
29 |
out = gr.Textbox(label="Response")
|
30 |
-
examples =
|
31 |
["",""" ****user \t hello \n ***assistant \t hi \n ****user \t how are you"""],
|
32 |
["what's 2+10",""" ****user \t hi \n ***assistant \t hello \n"""]
|
33 |
-
]
|
34 |
-
inputs=[prompt,history],
|
35 |
-
outputs=[out],
|
36 |
-
cache_examples=True)
|
37 |
|
38 |
-
iface = gr.Interface(fn=process,inputs=[prompt,history],outputs=[out])
|
39 |
iface.launch()
|
40 |
|
41 |
|
|
|
2 |
from transformers import Conversation, pipeline
|
3 |
from typing import Union
|
4 |
|
5 |
+
chatbot = pipeline("conversational", model="facebook/blenderbot-400M-distill")
|
6 |
|
7 |
def process(prompt:Union[str,None]=None,history:Union[str,None]=None):
|
8 |
"""" process prompt
|
|
|
27 |
prompt = gr.Textbox(label="Prompt")
|
28 |
history = gr.Textbox(label="History")
|
29 |
out = gr.Textbox(label="Response")
|
30 |
+
examples = [
|
31 |
["",""" ****user \t hello \n ***assistant \t hi \n ****user \t how are you"""],
|
32 |
["what's 2+10",""" ****user \t hi \n ***assistant \t hello \n"""]
|
33 |
+
]
|
|
|
|
|
|
|
34 |
|
35 |
+
iface = gr.Interface(fn=process,inputs=[prompt,history],outputs=[out],examples=examples,cache_examples=True)
|
36 |
iface.launch()
|
37 |
|
38 |
|