Update app.py
Browse files
app.py
CHANGED
@@ -128,6 +128,7 @@ def StreamLLMChatResponse(prompt):
|
|
128 |
res_box.markdown(f'*{result}*')
|
129 |
except:
|
130 |
st.write(' ')
|
|
|
131 |
except:
|
132 |
st.write('DromeLlama is asleep. Starting up now on A10 - please give 5 minutes then retry as KEDA scales up from zero to activate running container(s).')
|
133 |
|
@@ -388,7 +389,7 @@ def get_zip_download_link(zip_file):
|
|
388 |
return href
|
389 |
|
390 |
|
391 |
-
|
392 |
headers = {
|
393 |
"Authorization": "Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
394 |
"Content-Type": "audio/wav"
|
@@ -397,7 +398,7 @@ headers = {
|
|
397 |
def query(filename):
|
398 |
with open(filename, "rb") as f:
|
399 |
data = f.read()
|
400 |
-
response = requests.post(
|
401 |
return response.json()
|
402 |
|
403 |
def generate_filename(prompt, file_type):
|
@@ -422,7 +423,6 @@ def transcribe_audio(filename):
|
|
422 |
output = query(filename)
|
423 |
return output
|
424 |
|
425 |
-
|
426 |
def whisper_main():
|
427 |
st.title("Speech to Text")
|
428 |
st.write("Record your speech and get the text.")
|
@@ -432,39 +432,10 @@ def whisper_main():
|
|
432 |
if filename is not None:
|
433 |
transcription = transcribe_audio(filename)
|
434 |
st.write(transcription)
|
435 |
-
StreamLLMChatResponse(transcription)
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
"Generate Limericks: π": "Write ten random adult limericks based on quotes that are tweet length and make you laugh π",
|
440 |
-
"Wise Quotes: π§": "Generate ten wise quotes that are tweet length π¦",
|
441 |
-
"Funny Rhymes: π€": "Create ten funny rhymes that are tweet length πΆ",
|
442 |
-
"Medical Jokes: π": "Create ten medical jokes that are tweet length π₯",
|
443 |
-
"Minnesota Humor: βοΈ": "Create ten jokes about Minnesota that are tweet length π¨οΈ",
|
444 |
-
"Top Funny Stories: π": "Create ten funny stories that are tweet length π",
|
445 |
-
"More Funny Rhymes: ποΈ": "Create ten more funny rhymes that are tweet length π΅"
|
446 |
-
}
|
447 |
-
|
448 |
-
# Create columns
|
449 |
-
col1, col2, col3 = st.columns([1, 1, 1], gap="small")
|
450 |
-
|
451 |
-
# Add buttons to columns
|
452 |
-
if col1.button("Generate Limericks: π"):
|
453 |
-
StreamLLMChatResponse(descriptions["Generate Limericks: π"])
|
454 |
-
if col2.button("Wise Quotes π§"):
|
455 |
-
StreamLLMChatResponse(descriptions["Wise Quotes: π§"])
|
456 |
-
if col3.button("Funny Rhymes: π€"):
|
457 |
-
StreamLLMChatResponse(descriptions["Funny Rhymes: π€"])
|
458 |
-
col4, col5, col6 = st.columns([1, 1, 1], gap="small")
|
459 |
-
if col4.button("Medical Jokes: π"):
|
460 |
-
StreamLLMChatResponse(descriptions["Medical Jokes: π"])
|
461 |
-
if col5.button("Minnesota Humor βοΈ"):
|
462 |
-
StreamLLMChatResponse(descriptions["Minnesota Humor: βοΈ"])
|
463 |
-
if col6.button("Top Funny Stories π"):
|
464 |
-
StreamLLMChatResponse(descriptions["Top Funny Stories: π"])
|
465 |
-
col7 = st.columns(1, gap="small")
|
466 |
-
if col7[0].button("More Funny Rhymes: ποΈ"):
|
467 |
-
StreamLLMChatResponse(descriptions["More Funny Rhymes: ποΈ"])
|
468 |
|
469 |
def main():
|
470 |
|
|
|
128 |
res_box.markdown(f'*{result}*')
|
129 |
except:
|
130 |
st.write(' ')
|
131 |
+
return collected_messages
|
132 |
except:
|
133 |
st.write('DromeLlama is asleep. Starting up now on A10 - please give 5 minutes then retry as KEDA scales up from zero to activate running container(s).')
|
134 |
|
|
|
389 |
return href
|
390 |
|
391 |
|
392 |
+
API_URL_IE = f'https://tonpixzfvq3791u9.us-east-1.aws.endpoints.huggingface.cloud'
|
393 |
headers = {
|
394 |
"Authorization": "Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
395 |
"Content-Type": "audio/wav"
|
|
|
398 |
def query(filename):
|
399 |
with open(filename, "rb") as f:
|
400 |
data = f.read()
|
401 |
+
response = requests.post(API_URL_IE, headers=headers, data=data)
|
402 |
return response.json()
|
403 |
|
404 |
def generate_filename(prompt, file_type):
|
|
|
423 |
output = query(filename)
|
424 |
return output
|
425 |
|
|
|
426 |
def whisper_main():
|
427 |
st.title("Speech to Text")
|
428 |
st.write("Record your speech and get the text.")
|
|
|
432 |
if filename is not None:
|
433 |
transcription = transcribe_audio(filename)
|
434 |
st.write(transcription)
|
435 |
+
response = StreamLLMChatResponse(transcription)
|
436 |
+
filename = generate_filename(transcription, choice)
|
437 |
+
create_file(filename, user_prompt, response, should_save)
|
438 |
+
st.sidebar.markdown(get_table_download_link(filename), unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
439 |
|
440 |
def main():
|
441 |
|