Spaces:
Build error
Build error
Commit ·
a3ff15c
1
Parent(s): ad58fc4
fixes, tryed things with the prompt
Browse files
app.py
CHANGED
|
@@ -48,7 +48,7 @@ amy_voice = PiperVoice.load("./piper/en_US-amy-medium.onnx")
|
|
| 48 |
|
| 49 |
FIXED_PROMPT = "You are a helpful English Teaching Bot. You need to be friendly. Since you teach kids less than 7 years old, be motivating and don't point out any mistakes. Dont have long responses, keep your responses short. Assume I am your students and refer me as your student when replying"
|
| 50 |
llama_input_template = "<s> [INST] <<SYS>> {fixed_prompt} <</SYS>> Understand the story below and ask me one basic question regarding the story. Then wait for me to reply, when I reply, appreciate my participation and same way keep asking more questions one by one. Keep the questions one-liners and do not give much context. Keep everything brief \n {story_to_use} [/INST]"
|
| 51 |
-
llama_input_gen_random_story = f"<s> [INST] <<SYS>> You are a helpful English Teacher. You teach kids less than 7 years old.<</SYS>> Give me an english story for today's english learning session. Don't make it very big, say a few sentences. [/INST]"
|
| 52 |
|
| 53 |
@app.get("/webhook")
|
| 54 |
async def verify_webhook(request: Request):
|
|
@@ -119,10 +119,10 @@ def backgnd_process_message(message):
|
|
| 119 |
ONGOING_CONVO[sender_id]['Llama_conv'] = llama_input + llama_output + "</s> <s> [INST] "
|
| 120 |
else:
|
| 121 |
llama_input = ONGOING_CONVO[sender_id]['Llama_conv'] + message_text + "[/INST]"
|
| 122 |
-
|
| 123 |
logger.info(f"LLama Ouput: {llama_output}")
|
| 124 |
-
response_text =
|
| 125 |
-
ONGOING_CONVO[sender_id]['Llama_conv'] = llama_input +
|
| 126 |
elif message_type == "audio":
|
| 127 |
media_id = message["audio"]["id"]
|
| 128 |
audio_url = fetch_media_url(media_id)
|
|
@@ -139,10 +139,10 @@ def backgnd_process_message(message):
|
|
| 139 |
ONGOING_CONVO[sender_id]['Llama_conv'] = llama_input + llama_output + "</s> <s> [INST] "
|
| 140 |
else:
|
| 141 |
llama_input = ONGOING_CONVO[sender_id]['Llama_conv'] + transcription + "[/INST]"
|
| 142 |
-
|
| 143 |
logger.info(f"LLama Ouput: {llama_output}")
|
| 144 |
-
response_text =
|
| 145 |
-
ONGOING_CONVO[sender_id]['Llama_conv'] = llama_input +
|
| 146 |
elif message_type == "interactive":
|
| 147 |
if message["interactive"]["button_reply"]["id"] == "random_story":
|
| 148 |
ONGOING_CONVO[sender_id]['Story'] = "random_story"
|
|
@@ -232,7 +232,7 @@ def transcribe_audio(audio_path: str) -> str:
|
|
| 232 |
def convert_text_to_mp3(text, mp3_name = '/tmp/amy_said.mp3'):
|
| 233 |
text = re.sub(r"\*[^*]+\*", " ", text)
|
| 234 |
text = re.sub(r'[^A-Za-z0-9.,$ ]+', " ", text)
|
| 235 |
-
text = re.sub(r'\n',
|
| 236 |
text = text.encode('cp1252', 'ignore').decode('cp1252')
|
| 237 |
if text.isspace() or text == "":
|
| 238 |
return None
|
|
|
|
| 48 |
|
| 49 |
FIXED_PROMPT = "You are a helpful English Teaching Bot. You need to be friendly. Since you teach kids less than 7 years old, be motivating and don't point out any mistakes. Dont have long responses, keep your responses short. Assume I am your students and refer me as your student when replying"
|
| 50 |
llama_input_template = "<s> [INST] <<SYS>> {fixed_prompt} <</SYS>> Understand the story below and ask me one basic question regarding the story. Then wait for me to reply, when I reply, appreciate my participation and same way keep asking more questions one by one. Keep the questions one-liners and do not give much context. Keep everything brief \n {story_to_use} [/INST]"
|
| 51 |
+
llama_input_gen_random_story = f"<s> [INST] <<SYS>> You are a helpful English Teacher. You teach kids less than 7 years old.<</SYS>> Give me an english story for today's english learning session. Don't make it very big, say a few sentences. Just output the story nothing else, no chatting with me [/INST]"
|
| 52 |
|
| 53 |
@app.get("/webhook")
|
| 54 |
async def verify_webhook(request: Request):
|
|
|
|
| 119 |
ONGOING_CONVO[sender_id]['Llama_conv'] = llama_input + llama_output + "</s> <s> [INST] "
|
| 120 |
else:
|
| 121 |
llama_input = ONGOING_CONVO[sender_id]['Llama_conv'] + message_text + "[/INST]"
|
| 122 |
+
llama_output = hope_client.predict(inp = llama_input, api_name="/answer_question")
|
| 123 |
logger.info(f"LLama Ouput: {llama_output}")
|
| 124 |
+
response_text = llama_output
|
| 125 |
+
ONGOING_CONVO[sender_id]['Llama_conv'] = llama_input + llama_output + "</s> <s> [INST] "
|
| 126 |
elif message_type == "audio":
|
| 127 |
media_id = message["audio"]["id"]
|
| 128 |
audio_url = fetch_media_url(media_id)
|
|
|
|
| 139 |
ONGOING_CONVO[sender_id]['Llama_conv'] = llama_input + llama_output + "</s> <s> [INST] "
|
| 140 |
else:
|
| 141 |
llama_input = ONGOING_CONVO[sender_id]['Llama_conv'] + transcription + "[/INST]"
|
| 142 |
+
llama_output = hope_client.predict(inp = llama_input, api_name="/answer_question")
|
| 143 |
logger.info(f"LLama Ouput: {llama_output}")
|
| 144 |
+
response_text = llama_output
|
| 145 |
+
ONGOING_CONVO[sender_id]['Llama_conv'] = llama_input + llama_output + "</s> <s> [INST] "
|
| 146 |
elif message_type == "interactive":
|
| 147 |
if message["interactive"]["button_reply"]["id"] == "random_story":
|
| 148 |
ONGOING_CONVO[sender_id]['Story'] = "random_story"
|
|
|
|
| 232 |
def convert_text_to_mp3(text, mp3_name = '/tmp/amy_said.mp3'):
|
| 233 |
text = re.sub(r"\*[^*]+\*", " ", text)
|
| 234 |
text = re.sub(r'[^A-Za-z0-9.,$ ]+', " ", text)
|
| 235 |
+
text = re.sub(r'\n', " ", text)
|
| 236 |
text = text.encode('cp1252', 'ignore').decode('cp1252')
|
| 237 |
if text.isspace() or text == "":
|
| 238 |
return None
|