Spaces:
Sleeping
Sleeping
Mimi
commited on
Commit
·
a7eb66f
1
Parent(s):
8b075ef
Update prev commit
Browse files- .gitignore +2 -0
- Dockerfile +3 -1
- app.py +7 -23
- requirements.txt +3 -1
.gitignore
CHANGED
@@ -130,3 +130,5 @@ dmypy.json
|
|
130 |
.pyre/
|
131 |
|
132 |
.vscode/
|
|
|
|
|
|
130 |
.pyre/
|
131 |
|
132 |
.vscode/
|
133 |
+
model_hugger.py
|
134 |
+
*.key
|
Dockerfile
CHANGED
@@ -14,7 +14,9 @@ COPY . $HOME/app
|
|
14 |
RUN apt-get update && \
|
15 |
xargs -r -a /app/packages.txt apt-get install -y && \
|
16 |
rm -rf /var/lib/apt/lists/* && \
|
17 |
-
pip install --no-cache-dir -r $HOME/app/requirements.txt
|
|
|
|
|
18 |
|
19 |
EXPOSE 7860
|
20 |
CMD streamlit run app.py \
|
|
|
14 |
RUN apt-get update && \
|
15 |
xargs -r -a /app/packages.txt apt-get install -y && \
|
16 |
rm -rf /var/lib/apt/lists/* && \
|
17 |
+
pip install --no-cache-dir -r $HOME/app/requirements.txt && \
|
18 |
+
pip install llama-cpp-python \
|
19 |
+
--extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
|
20 |
|
21 |
EXPOSE 7860
|
22 |
CMD streamlit run app.py \
|
app.py
CHANGED
@@ -9,28 +9,13 @@
|
|
9 |
"""
|
10 |
|
11 |
import time
|
12 |
-
import random
|
13 |
import streamlit as st
|
14 |
-
from
|
15 |
-
|
16 |
-
# Streamed response emulator
|
17 |
-
def response_generator():
|
18 |
-
response = random.choice(
|
19 |
-
[
|
20 |
-
f"Hello there! {st.session_state['candidate_name']}",
|
21 |
-
f"Hi, {st.session_state['candidate_name']}! Is there anything I can help you with?",
|
22 |
-
f"Do you need help? {st.session_state['candidate_name']}",
|
23 |
-
]
|
24 |
-
)
|
25 |
-
for word in response.split():
|
26 |
-
yield word + " "
|
27 |
-
time.sleep(0.05)
|
28 |
|
29 |
# Title of the app
|
30 |
st.title("Chatbot Naomi")
|
31 |
|
32 |
print('Initial Session state', st.session_state)
|
33 |
-
|
34 |
contact_options = ['Instagram', 'Email', 'Number']
|
35 |
intake_form = [
|
36 |
'candidate_name',
|
@@ -40,8 +25,6 @@ intake_form = [
|
|
40 |
'candidate_location',
|
41 |
'intake_submission'
|
42 |
]
|
43 |
-
datetime_format = '%Y-%m-%d %H:%M:%S'
|
44 |
-
|
45 |
if "messages" not in st.session_state:
|
46 |
st.session_state.messages = []
|
47 |
|
@@ -66,6 +49,7 @@ def open_intake_form():
|
|
66 |
def open_chat_window(**kwargs):
|
67 |
# adds to current state (deletes if doesnt)
|
68 |
st.session_state.update(kwargs)
|
|
|
69 |
|
70 |
st.markdown('Welcome to the chat!')
|
71 |
msgbox = st.container(height=400, border=False)
|
@@ -78,20 +62,19 @@ def open_chat_window(**kwargs):
|
|
78 |
# Add user message to chat history
|
79 |
print(f'State: {st.session_state}\nUser inserted message: {user_input}')
|
80 |
|
81 |
-
st.session_state.messages.append({"role": "user", "content": user_input
|
82 |
# Display user message in chat message container
|
83 |
msgbox.chat_message("user").write(user_input)
|
84 |
-
response = msgbox.chat_message('assistant').write_stream(
|
85 |
|
86 |
# Append assistant's response to the messages history
|
87 |
-
st.session_state.messages.append({"role": "assistant", "content": response
|
88 |
|
89 |
undo_button, reset_button = st.columns(2)
|
90 |
if undo_button.button('Undo message', use_container_width=True, type='secondary'):
|
91 |
st.session_state['undo_button'] = True
|
92 |
if reset_button.button('Reset chat', use_container_width=True, type='primary'):
|
93 |
st.session_state.clear()
|
94 |
-
time.sleep(1)
|
95 |
st.rerun()
|
96 |
|
97 |
def main():
|
@@ -101,7 +84,8 @@ def main():
|
|
101 |
else:
|
102 |
st.session_state['candidate_name'] = st.session_state['candidate_name'].lower().capitalize()
|
103 |
open_chat_window(**st.session_state)
|
104 |
-
|
|
|
105 |
|
106 |
if __name__ == '__main__':
|
107 |
main()
|
|
|
9 |
"""
|
10 |
|
11 |
import time
|
|
|
12 |
import streamlit as st
|
13 |
+
from agent import Naomi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
# Title of the app
|
16 |
st.title("Chatbot Naomi")
|
17 |
|
18 |
print('Initial Session state', st.session_state)
|
|
|
19 |
contact_options = ['Instagram', 'Email', 'Number']
|
20 |
intake_form = [
|
21 |
'candidate_name',
|
|
|
25 |
'candidate_location',
|
26 |
'intake_submission'
|
27 |
]
|
|
|
|
|
28 |
if "messages" not in st.session_state:
|
29 |
st.session_state.messages = []
|
30 |
|
|
|
49 |
def open_chat_window(**kwargs):
|
50 |
# adds to current state (deletes if doesnt)
|
51 |
st.session_state.update(kwargs)
|
52 |
+
naomi = Naomi(**kwargs)
|
53 |
|
54 |
st.markdown('Welcome to the chat!')
|
55 |
msgbox = st.container(height=400, border=False)
|
|
|
62 |
# Add user message to chat history
|
63 |
print(f'State: {st.session_state}\nUser inserted message: {user_input}')
|
64 |
|
65 |
+
st.session_state.messages.append({"role": "user", "content": user_input})
|
66 |
# Display user message in chat message container
|
67 |
msgbox.chat_message("user").write(user_input)
|
68 |
+
response = msgbox.chat_message('assistant').write_stream(naomi.respond(st.session_state.messages))
|
69 |
|
70 |
# Append assistant's response to the messages history
|
71 |
+
st.session_state.messages.append({"role": "assistant", "content": response})
|
72 |
|
73 |
undo_button, reset_button = st.columns(2)
|
74 |
if undo_button.button('Undo message', use_container_width=True, type='secondary'):
|
75 |
st.session_state['undo_button'] = True
|
76 |
if reset_button.button('Reset chat', use_container_width=True, type='primary'):
|
77 |
st.session_state.clear()
|
|
|
78 |
st.rerun()
|
79 |
|
80 |
def main():
|
|
|
84 |
else:
|
85 |
st.session_state['candidate_name'] = st.session_state['candidate_name'].lower().capitalize()
|
86 |
open_chat_window(**st.session_state)
|
87 |
+
|
88 |
+
# render_agent_mood()
|
89 |
|
90 |
if __name__ == '__main__':
|
91 |
main()
|
requirements.txt
CHANGED
@@ -1,2 +1,4 @@
|
|
1 |
streamlit
|
2 |
-
requests
|
|
|
|
|
|
1 |
streamlit
|
2 |
+
requests
|
3 |
+
transformers
|
4 |
+
accelerate
|