giannicrivello
commited on
Commit
•
daad2f6
1
Parent(s):
92478d4
test chat bot
Browse files- test/__pycache__/app.cpython-39.pyc +0 -0
- test/app.py +36 -0
- test/gradio_cached_examples/111/component 0/tmpn88ijobr.json +1 -0
- test/gradio_cached_examples/111/log.csv +2 -0
- test/gradio_cached_examples/130/component 0/tmpv90vfemf.json +1 -0
- test/gradio_cached_examples/130/log.csv +2 -0
- test/gradio_cached_examples/149/component 0/tmpx7qufp1b.json +1 -0
- test/gradio_cached_examples/149/log.csv +2 -0
- test/gradio_cached_examples/16/component 0/tmpnqiknitn.json +1 -0
- test/gradio_cached_examples/16/log.csv +2 -0
- test/gradio_cached_examples/168/component 0/tmpl3jpwec1.json +1 -0
- test/gradio_cached_examples/168/log.csv +2 -0
- test/gradio_cached_examples/187/component 0/tmpnci004lt.json +1 -0
- test/gradio_cached_examples/187/log.csv +2 -0
- test/gradio_cached_examples/206/component 0/tmptn0jb2fg.json +1 -0
- test/gradio_cached_examples/206/log.csv +2 -0
- test/gradio_cached_examples/225/component 0/tmpq13gt0do.json +1 -0
- test/gradio_cached_examples/225/log.csv +2 -0
- test/gradio_cached_examples/244/component 0/tmpxi5sbnk_.json +1 -0
- test/gradio_cached_examples/244/log.csv +2 -0
- test/gradio_cached_examples/263/component 0/tmpbp_tqp4j.json +1 -0
- test/gradio_cached_examples/263/log.csv +2 -0
- test/gradio_cached_examples/282/component 0/tmp1wmx5_dh.json +1 -0
- test/gradio_cached_examples/282/log.csv +2 -0
- test/gradio_cached_examples/35/component 0/tmp_bt5kz6p.json +1 -0
- test/gradio_cached_examples/35/log.csv +2 -0
- test/gradio_cached_examples/54/component 0/tmpdcf2zlu2.json +1 -0
- test/gradio_cached_examples/54/log.csv +2 -0
- test/gradio_cached_examples/73/component 0/tmp9vh8zb_q.json +1 -0
- test/gradio_cached_examples/73/log.csv +2 -0
- test/gradio_cached_examples/92/component 0/tmpad_ajgs3.json +1 -0
- test/gradio_cached_examples/92/log.csv +2 -0
test/__pycache__/app.cpython-39.pyc
ADDED
Binary file (1.04 kB). View file
|
|
test/app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
from transformers import Conversation
|
4 |
+
|
5 |
+
pipe = pipeline("conversational", model="PygmalionAI/pygmalion-6b")
|
6 |
+
conversation = Conversation()
|
7 |
+
conversation.add_message({"role": "assistant", "content": "How can I help you?"})
|
8 |
+
memory = []
|
9 |
+
|
10 |
+
def run_conversation(message, history):
|
11 |
+
#cache memory from user
|
12 |
+
memory.append({"role": "user", "content": message})
|
13 |
+
print(history)
|
14 |
+
|
15 |
+
if len(history) > 0:
|
16 |
+
for i in history:
|
17 |
+
conversation.add_message({"role":"user", "content":i[0]})
|
18 |
+
conversation.add_message({"role": "assistant", "content": i[1]})
|
19 |
+
for i in memory:
|
20 |
+
conversation.add_message(i)
|
21 |
+
print(conversation)
|
22 |
+
|
23 |
+
pipe(conversation)
|
24 |
+
return conversation.generated_responses[-1]
|
25 |
+
|
26 |
+
demo = gr.ChatInterface(
|
27 |
+
run_conversation,
|
28 |
+
chatbot = gr.Chatbot(height=500),
|
29 |
+
textbox = gr.Textbox(placeholder="Chat with me!", scale=7),
|
30 |
+
title = "Test",
|
31 |
+
description="Chat with me!"
|
32 |
+
)
|
33 |
+
|
34 |
+
if __name__ == "__main__":
|
35 |
+
demo.queue().launch()
|
36 |
+
|
test/gradio_cached_examples/111/component 0/tmpn88ijobr.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[["hello", "Ask me anything!"]]
|
test/gradio_cached_examples/111/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
component 0,flag,username,timestamp
|
2 |
+
/Users/giannicrivello/test/test/gradio_cached_examples/111/component 0/tmpn88ijobr.json,,,2023-10-20 23:26:23.398744
|
test/gradio_cached_examples/130/component 0/tmpv90vfemf.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[["hello", "Ask me anything!"]]
|
test/gradio_cached_examples/130/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
component 0,flag,username,timestamp
|
2 |
+
/Users/giannicrivello/test/test/gradio_cached_examples/130/component 0/tmpv90vfemf.json,,,2023-10-20 23:26:23.421564
|
test/gradio_cached_examples/149/component 0/tmpx7qufp1b.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[["hello", "Ask me anything!"]]
|
test/gradio_cached_examples/149/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
component 0,flag,username,timestamp
|
2 |
+
/Users/giannicrivello/test/test/gradio_cached_examples/149/component 0/tmpx7qufp1b.json,,,2023-10-20 23:26:28.316716
|
test/gradio_cached_examples/16/component 0/tmpnqiknitn.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[["hello", "Ask me anything!"]]
|
test/gradio_cached_examples/16/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
component 0,flag,username,timestamp
|
2 |
+
/Users/giannicrivello/test/test/gradio_cached_examples/16/component 0/tmpnqiknitn.json,,,2023-10-20 23:25:02.499698
|
test/gradio_cached_examples/168/component 0/tmpl3jpwec1.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[["hello", "Ask me anything!"]]
|
test/gradio_cached_examples/168/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
component 0,flag,username,timestamp
|
2 |
+
/Users/giannicrivello/test/test/gradio_cached_examples/168/component 0/tmpl3jpwec1.json,,,2023-10-20 23:26:28.338939
|
test/gradio_cached_examples/187/component 0/tmpnci004lt.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[["hello", "Ask me anything!"]]
|
test/gradio_cached_examples/187/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
component 0,flag,username,timestamp
|
2 |
+
/Users/giannicrivello/test/test/gradio_cached_examples/187/component 0/tmpnci004lt.json,,,2023-10-20 23:26:33.702516
|
test/gradio_cached_examples/206/component 0/tmptn0jb2fg.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[["hello", "Ask me anything!"]]
|
test/gradio_cached_examples/206/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
component 0,flag,username,timestamp
|
2 |
+
/Users/giannicrivello/test/test/gradio_cached_examples/206/component 0/tmptn0jb2fg.json,,,2023-10-20 23:26:33.724947
|
test/gradio_cached_examples/225/component 0/tmpq13gt0do.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[["hello", "Ask me anything!"]]
|
test/gradio_cached_examples/225/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
component 0,flag,username,timestamp
|
2 |
+
/Users/giannicrivello/test/test/gradio_cached_examples/225/component 0/tmpq13gt0do.json,,,2023-10-20 23:26:38.859656
|
test/gradio_cached_examples/244/component 0/tmpxi5sbnk_.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[["hello", "Ask me anything!"]]
|
test/gradio_cached_examples/244/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
component 0,flag,username,timestamp
|
2 |
+
/Users/giannicrivello/test/test/gradio_cached_examples/244/component 0/tmpxi5sbnk_.json,,,2023-10-20 23:26:38.881435
|
test/gradio_cached_examples/263/component 0/tmpbp_tqp4j.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[["hello", "Ask me anything!"]]
|
test/gradio_cached_examples/263/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
component 0,flag,username,timestamp
|
2 |
+
/Users/giannicrivello/test/test/gradio_cached_examples/263/component 0/tmpbp_tqp4j.json,,,2023-10-20 23:26:45.410929
|
test/gradio_cached_examples/282/component 0/tmp1wmx5_dh.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[["hello", "Ask me anything!"]]
|
test/gradio_cached_examples/282/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
component 0,flag,username,timestamp
|
2 |
+
/Users/giannicrivello/test/test/gradio_cached_examples/282/component 0/tmp1wmx5_dh.json,,,2023-10-20 23:26:45.433902
|
test/gradio_cached_examples/35/component 0/tmp_bt5kz6p.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[["hello", "Ask me anything!"]]
|
test/gradio_cached_examples/35/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
component 0,flag,username,timestamp
|
2 |
+
/Users/giannicrivello/test/test/gradio_cached_examples/35/component 0/tmp_bt5kz6p.json,,,2023-10-20 23:25:28.736080
|
test/gradio_cached_examples/54/component 0/tmpdcf2zlu2.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[["hello", "Ask me anything!"]]
|
test/gradio_cached_examples/54/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
component 0,flag,username,timestamp
|
2 |
+
/Users/giannicrivello/test/test/gradio_cached_examples/54/component 0/tmpdcf2zlu2.json,,,2023-10-20 23:25:28.757606
|
test/gradio_cached_examples/73/component 0/tmp9vh8zb_q.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[["hello", "Ask me anything!"]]
|
test/gradio_cached_examples/73/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
component 0,flag,username,timestamp
|
2 |
+
/Users/giannicrivello/test/test/gradio_cached_examples/73/component 0/tmp9vh8zb_q.json,,,2023-10-20 23:25:35.161726
|
test/gradio_cached_examples/92/component 0/tmpad_ajgs3.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[["hello", "Ask me anything!"]]
|
test/gradio_cached_examples/92/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
component 0,flag,username,timestamp
|
2 |
+
/Users/giannicrivello/test/test/gradio_cached_examples/92/component 0/tmpad_ajgs3.json,,,2023-10-20 23:25:35.183794
|