N.Achyuth Reddy commited on
Commit
e20f46f
·
verified ·
1 Parent(s): a8f2e67

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -40,9 +40,9 @@ def transcribe(wav_path):
40
  def predict(message, system_prompt='Your name is FlawlessAI. You are developed by Achyuth. Your developer is a 14-year old boy, who is intrested on AI and Machine Learning. Dont talk about your developers age, until the user asks for your developers age. You need to give the user a long and big text as output with useful information. When the user asks you for information, never exclaim the words, and directly come to point and answer to the user. You need to provide short text-answers, meaningful answers and directly to the point. Never miscalculate the calculations. You need to check and verify the answer and then provide to user, the correct answer. You need to provide accurate and correct information. If the user conveys with you in any language, you also should convey in the same language', temperature=0.7, max_new_tokens=2048, Topp=0.5, Repetitionpenalty=1.2):
41
  with st.status("sᴛᴀʀᴛɪɴɢ ᴄʟɪᴇɴᴛ..."):
42
  client = Client("https://huggingface-projects-llama-2-13b-chat.hf.space/")
43
- st.write("ʀᴇǫᴜᴇsᴛɪɴɢ ᴀᴜᴅɪᴏ ᴛʀᴀɴsᴄʀɪʙᴇʀ...")
44
- with st.status("ʀᴇǫᴜᴇsᴛɪɴɢ ғʟᴀᴡʟᴇssᴀɪ-ʟʟᴍ..."):
45
- st.write("ʀᴇǫᴜᴇsᴛɪɴɢ ᴀᴘɪ...")
46
  response = client.predict(
47
  message,
48
  system_prompt,
@@ -53,7 +53,7 @@ def predict(message, system_prompt='Your name is FlawlessAI. You are developed b
53
  Repetitionpenalty,
54
  api_name="/chat"
55
  )
56
- st.write("ꜱᴜᴄᴄᴇꜱꜱ ✅")
57
  return response
58
 
59
  # Streamlit UI
@@ -68,16 +68,16 @@ for message in st.session_state.messages:
68
  with st.chat_message(message["role"], avatar=("🧑‍💻" if message["role"] == 'human' else '🦙')):
69
  st.markdown(message["content"])
70
 
71
- textinput = st.chat_input("ᴀsᴋ 𝗙𝗹𝗮𝘄𝗹𝗲𝘀𝘀𝗔𝗜 ᴀɴʏᴛʜɪɴɢ...")
72
  wav_audio_data = st_audiorec()
73
 
74
  if wav_audio_data is not None:
75
- with st.status("ᴛʀᴀɴsᴄʀɪʙɪɴɢ ᴀᴜᴅɪᴏ..."):
76
  # save audio
77
  with open("audio.wav", "wb") as f:
78
  f.write(wav_audio_data)
79
  prompt = transcribe("audio.wav")
80
- st.write("ᴛʀᴀɴsᴄʀɪʙᴇᴅ ᴀᴜᴅɪᴏ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ✅")
81
 
82
  st.chat_message("human", avatar="😎").markdown(prompt)
83
  st.session_state.messages.append({"role": "human", "content": prompt})
 
40
  def predict(message, system_prompt='Your name is FlawlessAI. You are developed by Achyuth. Your developer is a 14-year old boy, who is intrested on AI and Machine Learning. Dont talk about your developers age, until the user asks for your developers age. You need to give the user a long and big text as output with useful information. When the user asks you for information, never exclaim the words, and directly come to point and answer to the user. You need to provide short text-answers, meaningful answers and directly to the point. Never miscalculate the calculations. You need to check and verify the answer and then provide to user, the correct answer. You need to provide accurate and correct information. If the user conveys with you in any language, you also should convey in the same language', temperature=0.7, max_new_tokens=2048, Topp=0.5, Repetitionpenalty=1.2):
41
  with st.status("sᴛᴀʀᴛɪɴɢ ᴄʟɪᴇɴᴛ..."):
42
  client = Client("https://huggingface-projects-llama-2-13b-chat.hf.space/")
43
+ st.write("Requesting audio transcriber...")
44
+ with st.status("Requesting Flawless-LLM..."):
45
+ st.write("Requesting API...")
46
  response = client.predict(
47
  message,
48
  system_prompt,
 
53
  Repetitionpenalty,
54
  api_name="/chat"
55
  )
56
+ st.write("Success ✅")
57
  return response
58
 
59
  # Streamlit UI
 
68
  with st.chat_message(message["role"], avatar=("🧑‍💻" if message["role"] == 'human' else '🦙')):
69
  st.markdown(message["content"])
70
 
71
+ textinput = st.chat_input("Ask FlawlessAI anything...")
72
  wav_audio_data = st_audiorec()
73
 
74
  if wav_audio_data is not None:
75
+ with st.status("Transcribing audio..."):
76
  # save audio
77
  with open("audio.wav", "wb") as f:
78
  f.write(wav_audio_data)
79
  prompt = transcribe("audio.wav")
80
+ st.write("Transcribed audio successfully ✅")
81
 
82
  st.chat_message("human", avatar="😎").markdown(prompt)
83
  st.session_state.messages.append({"role": "human", "content": prompt})