Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
# version - ArcticMonkeys:30.07.24
|
2 |
|
3 |
# python core libraries
|
|
|
4 |
import psutil
|
5 |
# streamlit
|
6 |
import streamlit as st
|
@@ -26,6 +27,12 @@ doc = Documentation()
|
|
26 |
chat = Conversation()
|
27 |
t2a = T2A()
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
def main():
|
30 |
try:
|
31 |
mic = mic_recorder(start_prompt="Record", stop_prompt="Stop", just_once=True, use_container_width=True)
|
@@ -36,11 +43,12 @@ def main():
|
|
36 |
|
37 |
prompt = select_prompt(input_text=text, prompts=prompts, keywords=keywords)
|
38 |
print(f"Prompt:\n{prompt}")
|
39 |
-
|
|
|
40 |
t2a.autoplay(response)
|
41 |
|
42 |
if response:
|
43 |
-
st.markdown(f"Your input: {prompt}")
|
44 |
st.markdown(f"Chelsea response: {response}")
|
45 |
|
46 |
prompt = None
|
|
|
1 |
# version - ArcticMonkeys:30.07.24
|
2 |
|
3 |
# python core libraries
|
4 |
+
import re
|
5 |
import psutil
|
6 |
# streamlit
|
7 |
import streamlit as st
|
|
|
27 |
chat = Conversation()
|
28 |
t2a = T2A()
|
29 |
|
30 |
+
def remove_labels_with_regex(text: str):
|
31 |
+
pattern = r'^(Human:|AI:|Chelsea:)\s*'
|
32 |
+
cleaned_text = re.sub(pattern, '', text, flags=re.MULTILINE)
|
33 |
+
return cleaned_text
|
34 |
+
|
35 |
+
|
36 |
def main():
|
37 |
try:
|
38 |
mic = mic_recorder(start_prompt="Record", stop_prompt="Stop", just_once=True, use_container_width=True)
|
|
|
43 |
|
44 |
prompt = select_prompt(input_text=text, prompts=prompts, keywords=keywords)
|
45 |
print(f"Prompt:\n{prompt}")
|
46 |
+
output_from_chat = chat.chatting(prompt=prompt if prompt is not None else text)
|
47 |
+
response = remove_labels_with_regex(text=output_from_chat)
|
48 |
t2a.autoplay(response)
|
49 |
|
50 |
if response:
|
51 |
+
st.markdown(f"Your input: {prompt['Question']}")
|
52 |
st.markdown(f"Chelsea response: {response}")
|
53 |
|
54 |
prompt = None
|