awacke1 commited on
Commit
17dde27
β€’
1 Parent(s): 6334f83

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -36
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
- API_URL = f'https://tonpixzfvq3791u9.us-east-1.aws.endpoints.huggingface.cloud'
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(API_URL, headers=headers, data=data)
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
- # Define button descriptions
438
- descriptions = {
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