Spaces:
Sleeping
Sleeping
suggested fix
Browse files- .gitignore +145 -0
- __pycache__/agent.cpython-310.pyc +0 -0
- __pycache__/chatbox.cpython-310.pyc +0 -0
- __pycache__/chatui.cpython-310.pyc +0 -0
- __pycache__/footer.cpython-310.pyc +0 -0
- __pycache__/header.cpython-310.pyc +0 -0
- __pycache__/utils.cpython-310.pyc +0 -0
- app.py +1 -18
- chatbox.py +5 -7
.gitignore
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.DS_Store
|
2 |
+
|
3 |
+
# Byte-compiled / optimized / DLL files
|
4 |
+
__pycache__/
|
5 |
+
crawlers/__pycache__/
|
6 |
+
core/__pycache__/
|
7 |
+
*.py[cod]
|
8 |
+
*$py.class
|
9 |
+
|
10 |
+
# C extensions
|
11 |
+
*.so
|
12 |
+
|
13 |
+
# Distribution / packaging
|
14 |
+
.Python
|
15 |
+
build/
|
16 |
+
develop-eggs/
|
17 |
+
dist/
|
18 |
+
downloads/
|
19 |
+
eggs/
|
20 |
+
.eggs/
|
21 |
+
lib/
|
22 |
+
lib64/
|
23 |
+
parts/
|
24 |
+
sdist/
|
25 |
+
var/
|
26 |
+
wheels/
|
27 |
+
pip-wheel-metadata/
|
28 |
+
share/python-wheels/
|
29 |
+
*.egg-info/
|
30 |
+
.installed.cfg
|
31 |
+
*.egg
|
32 |
+
MANIFEST
|
33 |
+
|
34 |
+
# PyInstaller
|
35 |
+
# Usually these files are written by a python script from a template
|
36 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
37 |
+
*.manifest
|
38 |
+
*.spec
|
39 |
+
|
40 |
+
# Installer logs
|
41 |
+
pip-log.txt
|
42 |
+
pip-delete-this-directory.txt
|
43 |
+
|
44 |
+
# Unit test / coverage reports
|
45 |
+
htmlcov/
|
46 |
+
.tox/
|
47 |
+
.nox/
|
48 |
+
.coverage
|
49 |
+
.coverage.*
|
50 |
+
.cache
|
51 |
+
nosetests.xml
|
52 |
+
coverage.xml
|
53 |
+
*.cover
|
54 |
+
*.py,cover
|
55 |
+
.hypothesis/
|
56 |
+
.pytest_cache/
|
57 |
+
|
58 |
+
# Translations
|
59 |
+
*.mo
|
60 |
+
*.pot
|
61 |
+
|
62 |
+
# Django stuff:
|
63 |
+
*.log
|
64 |
+
local_settings.py
|
65 |
+
db.sqlite3
|
66 |
+
db.sqlite3-journal
|
67 |
+
|
68 |
+
# Flask stuff:
|
69 |
+
instance/
|
70 |
+
.webassets-cache
|
71 |
+
|
72 |
+
# Scrapy stuff:
|
73 |
+
.scrapy
|
74 |
+
|
75 |
+
# Sphinx documentation
|
76 |
+
docs/_build/
|
77 |
+
|
78 |
+
# PyBuilder
|
79 |
+
target/
|
80 |
+
|
81 |
+
# Jupyter Notebook
|
82 |
+
.ipynb_checkpoints
|
83 |
+
|
84 |
+
# IPython
|
85 |
+
profile_default/
|
86 |
+
ipython_config.py
|
87 |
+
|
88 |
+
# pyenv
|
89 |
+
.python-version
|
90 |
+
|
91 |
+
# pipenv
|
92 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
93 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
94 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
95 |
+
# install all needed dependencies.
|
96 |
+
#Pipfile.lock
|
97 |
+
|
98 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
99 |
+
__pypackages__/
|
100 |
+
|
101 |
+
# Celery stuff
|
102 |
+
celerybeat-schedule
|
103 |
+
celerybeat.pid
|
104 |
+
|
105 |
+
# SageMath parsed files
|
106 |
+
*.sage.py
|
107 |
+
|
108 |
+
# Environments
|
109 |
+
.env
|
110 |
+
.env*
|
111 |
+
.venv
|
112 |
+
env/
|
113 |
+
venv/
|
114 |
+
ENV/
|
115 |
+
env.bak/
|
116 |
+
venv.bak/
|
117 |
+
|
118 |
+
# secrets file in TOML format
|
119 |
+
secrets.toml
|
120 |
+
|
121 |
+
# Any GDrive credentials file
|
122 |
+
credentials.json
|
123 |
+
|
124 |
+
# Spyder project settings
|
125 |
+
.spyderproject
|
126 |
+
.spyproject
|
127 |
+
|
128 |
+
# Rope project settings
|
129 |
+
.ropeproject
|
130 |
+
|
131 |
+
# mkdocs documentation
|
132 |
+
/site
|
133 |
+
|
134 |
+
# mypy
|
135 |
+
.mypy_cache/
|
136 |
+
.dmypy.json
|
137 |
+
dmypy.json
|
138 |
+
|
139 |
+
# Pyre type checker
|
140 |
+
.pyre/
|
141 |
+
|
142 |
+
# project file
|
143 |
+
project.yaml
|
144 |
+
|
145 |
+
.idea/
|
__pycache__/agent.cpython-310.pyc
DELETED
Binary file (10.3 kB)
|
|
__pycache__/chatbox.cpython-310.pyc
DELETED
Binary file (1.75 kB)
|
|
__pycache__/chatui.cpython-310.pyc
DELETED
Binary file (4.76 kB)
|
|
__pycache__/footer.cpython-310.pyc
DELETED
Binary file (1.85 kB)
|
|
__pycache__/header.cpython-310.pyc
DELETED
Binary file (2.33 kB)
|
|
__pycache__/utils.cpython-310.pyc
DELETED
Binary file (195 Bytes)
|
|
app.py
CHANGED
@@ -70,12 +70,7 @@ def App():
|
|
70 |
{"user": "bot", "message": response},
|
71 |
]
|
72 |
)
|
73 |
-
|
74 |
-
# {"user": "human", "message": sent_message},
|
75 |
-
# {"user": "bot", "message": response},
|
76 |
-
# ])
|
77 |
-
# set_show_logs_button(True)
|
78 |
-
|
79 |
def send_message(event=None):
|
80 |
if message.strip():
|
81 |
sent_message = message
|
@@ -97,15 +92,6 @@ def App():
|
|
97 |
|
98 |
asyncio.create_task(send_message_async(sent_message))
|
99 |
|
100 |
-
# async def handle_key_down(event):
|
101 |
-
# def handle_key_down(event, user_message=""):
|
102 |
-
# if event['key'] == 'Enter' and message.strip():
|
103 |
-
# set_message(user_message)
|
104 |
-
# send_message()
|
105 |
-
|
106 |
-
def handle_input_change(event):
|
107 |
-
set_message(event['target']['value'])
|
108 |
-
|
109 |
return html.div(
|
110 |
{
|
111 |
"style": {
|
@@ -147,13 +133,10 @@ def App():
|
|
147 |
show_logs_button=show_logs_button,
|
148 |
collapsed=collapsed
|
149 |
),
|
150 |
-
# ChatBox(message, set_message, handle_input_change, handle_key_down, send_message, collapsed),
|
151 |
ChatBox(message, set_message, send_message, collapsed),
|
152 |
Footer(collapsed, set_collapsed),
|
153 |
)
|
154 |
|
155 |
-
# app = Starlette()
|
156 |
-
# configure(app, App)
|
157 |
|
158 |
if __name__ == "__main__":
|
159 |
run(App)
|
|
|
70 |
{"user": "bot", "message": response},
|
71 |
]
|
72 |
)
|
73 |
+
|
|
|
|
|
|
|
|
|
|
|
74 |
def send_message(event=None):
|
75 |
if message.strip():
|
76 |
sent_message = message
|
|
|
92 |
|
93 |
asyncio.create_task(send_message_async(sent_message))
|
94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
return html.div(
|
96 |
{
|
97 |
"style": {
|
|
|
133 |
show_logs_button=show_logs_button,
|
134 |
collapsed=collapsed
|
135 |
),
|
|
|
136 |
ChatBox(message, set_message, send_message, collapsed),
|
137 |
Footer(collapsed, set_collapsed),
|
138 |
)
|
139 |
|
|
|
|
|
140 |
|
141 |
if __name__ == "__main__":
|
142 |
run(App)
|
chatbox.py
CHANGED
@@ -5,12 +5,11 @@ from reactpy.core.hooks import use_ref
|
|
5 |
# def ChatBox(message, set_message, handle_input_change, handle_key_down, send_message, collapsed):
|
6 |
def ChatBox(message, set_message, send_message, collapsed):
|
7 |
|
8 |
-
|
|
|
9 |
|
10 |
def handle_key_down(event):
|
11 |
-
|
12 |
-
if event['key'] == 'Enter' and user_message.strip():
|
13 |
-
set_message(user_message)
|
14 |
send_message()
|
15 |
|
16 |
return html.div(
|
@@ -31,10 +30,9 @@ def ChatBox(message, set_message, send_message, collapsed):
|
|
31 |
html.input(
|
32 |
{
|
33 |
"type": "text",
|
34 |
-
"value":
|
35 |
"placeholder": "Your Message",
|
36 |
-
|
37 |
-
# "onKeyDown": handle_key_down,
|
38 |
"onKeyDown": handle_key_down,
|
39 |
"style": {
|
40 |
"width": "100%",
|
|
|
5 |
# def ChatBox(message, set_message, handle_input_change, handle_key_down, send_message, collapsed):
|
6 |
def ChatBox(message, set_message, send_message, collapsed):
|
7 |
|
8 |
+
def handle_input_change(event):
|
9 |
+
set_message(event['target']['value'])
|
10 |
|
11 |
def handle_key_down(event):
|
12 |
+
if event['key'] == 'Enter' and message.strip():
|
|
|
|
|
13 |
send_message()
|
14 |
|
15 |
return html.div(
|
|
|
30 |
html.input(
|
31 |
{
|
32 |
"type": "text",
|
33 |
+
"value": message,
|
34 |
"placeholder": "Your Message",
|
35 |
+
"onChange": handle_input_change,
|
|
|
36 |
"onKeyDown": handle_key_down,
|
37 |
"style": {
|
38 |
"width": "100%",
|