awacke1 commited on
Commit
f9f3b61
·
verified ·
1 Parent(s): cfb39dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -123
app.py CHANGED
@@ -1335,118 +1335,49 @@ def transcribe_canary(filename):
1335
  )
1336
  st.write(result)
1337
  return result
1338
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1339
  filename = save_and_play_audio(audio_recorder)
1340
  if filename is not None:
1341
  transcript=''
1342
-
1343
  transcript=transcribe_canary(filename)
 
 
1344
  result = search_arxiv(transcript)
1345
- #result2 = search_glossary(result)
1346
- #st.markdown(result)
1347
- #st.markdown
1348
 
1349
-
1350
- #transcription = transcribe_audio(filename)
1351
- #try:
1352
- # transcript = transcription['text']
1353
- # st.write(transcript)
1354
-
1355
- #except:
1356
- # transcript=''
1357
- # st.write(transcript)
1358
-
1359
- #st.write('Reasoning with your inputs..')
1360
- #response = chat_with_model(transcript)
1361
- #st.write('Response:')
1362
- #st.write(response)
1363
- #filename = generate_filename(response, "txt")
1364
- #create_file(filename, transcript, response, should_save)
1365
 
1366
- # Whisper to Llama:
1367
- st.write('Running StreamLLMChatResponse on transcript because audio wav was there passing transcript' + transcript)
1368
- response = StreamLLMChatResponse(transcript)
1369
- filename_txt = generate_filename(transcript, "md")
1370
- create_file(filename_txt, transcript, response, should_save)
1371
- filename_wav = filename_txt.replace('.txt', '.wav')
1372
- import shutil
1373
- try:
1374
- if os.path.exists(filename):
1375
- shutil.copyfile(filename, filename_wav)
1376
- except:
1377
- st.write('.')
1378
- if os.path.exists(filename):
1379
- os.remove(filename)
1380
-
1381
-
1382
-
1383
-
1384
- prompt = '''
1385
- What is MoE?
1386
- What are Multi Agent Systems?
1387
- What is Self Rewarding AI?
1388
- What is Semantic and Episodic memory?
1389
- What is AutoGen?
1390
- What is ChatDev?
1391
- What is Omniverse?
1392
- What is Lumiere?
1393
- What is SORA?
1394
- '''
1395
-
1396
- import streamlit as st
1397
-
1398
- personality_factors = """
1399
- 1. 🌈 Openness (Being open to new things)
1400
- - 🎭 Imagination (Enjoying fantasy and daydreaming)
1401
- - 🎨 Artistic Interests (Appreciating beauty and art)
1402
- - 🎸 Creativity (Coming up with new ideas)
1403
- - 🌍 Curiosity (Wanting to explore and learn)
1404
- - 🌿 Unconventional (Being different and unique)
1405
- - 🧩 Complexity (Enjoying deep thoughts and feelings)
1406
- - 🌌 Adventurousness (Seeking new experiences)
1407
-
1408
- 2. 💼 Conscientiousness (Being organized and reliable)
1409
- - 🎯 Competence (Feeling capable and effective)
1410
- - 📊 Orderliness (Keeping things neat and tidy)
1411
- - 📅 Dutifulness (Following rules and doing what's right)
1412
- - 🏆 Achievement (Working hard to reach goals)
1413
- - 🧘‍♀️ Self-Discipline (Staying focused and in control)
1414
- - 🤔 Thoughtfulness (Thinking before acting)
1415
- - 🕰️ Time Management (Using time wisely)
1416
- - 🧽 Perfectionism (Wanting things to be just right)
1417
-
1418
- 3. 🎉 Extraversion (Being outgoing and social)
1419
- - 🤗 Friendliness (Being kind and welcoming)
1420
- - 👥 Sociability (Enjoying being with others)
1421
- - 🗣️ Assertiveness (Speaking up and taking charge)
1422
- - ⚡ Energy (Being active and lively)
1423
- - 🎢 Excitement (Seeking thrills and fun)
1424
- - 😊 Cheerfulness (Feeling happy and positive)
1425
- - 🎤 Talkativeness (Enjoying conversation)
1426
- - 🌞 Enthusiasm (Showing excitement and interest)
1427
-
1428
- 4. 🤝 Agreeableness (Being kind and cooperative)
1429
- - 🤲 Trust (Believing in others' goodness)
1430
- - 🌿 Honesty (Being truthful and sincere)
1431
- - 🤝 Cooperation (Working well with others)
1432
- - 🌸 Helpfulness (Being generous and caring)
1433
- - 🕊️ Compliance (Following rules and respecting authority)
1434
- - 🙏 Modesty (Being humble and down-to-earth)
1435
- - 💕 Empathy (Understanding others' feelings)
1436
- - 🫂 Compassion (Caring about others' well-being)
1437
-
1438
- 5. 😔 Neuroticism (Feeling negative emotions easily)
1439
- - 😰 Anxiety (Worrying and feeling nervous)
1440
- - 😡 Anger (Getting upset and frustrated)
1441
- - 😢 Sadness (Feeling down and unhappy)
1442
- - 😳 Self-Consciousness (Feeling shy and uneasy)
1443
- - 🎢 Impulsiveness (Acting without thinking)
1444
- - 🍃 Vulnerability (Being easily hurt or upset)
1445
- - 🌪️ Moodiness (Having ups and downs in feelings)
1446
- - 🎭 Negativity (Focusing on the bad side of things)
1447
- """
1448
-
1449
 
 
1450
  session_state = {}
1451
  if "search_queries" not in session_state:
1452
  session_state["search_queries"] = []
@@ -1478,8 +1409,6 @@ if openai.api_key == None: openai.api_key = st.secrets['OPENAI_API_KEY']
1478
  menu = ["txt", "htm", "xlsx", "csv", "md", "py"]
1479
  choice = st.sidebar.selectbox("Output File Type:", menu)
1480
 
1481
- #model_choice = st.sidebar.radio("Select Model:", ('gpt-3.5-turbo', 'gpt-3.5-turbo-0301'))
1482
- #user_prompt = st.text_area("Enter prompts, instructions & questions:", '', height=100)
1483
  AddAFileForContext=False
1484
  if AddAFileForContext:
1485
 
@@ -1781,17 +1710,6 @@ if showExtendedTextInterface:
1781
  display_images_and_wikipedia_summaries(num_columns_images) # Image Jump Grid
1782
 
1783
 
1784
- def process_text2(MODEL='gpt-4o-2024-05-13', text_input='What is 2+2 and what is an imaginary number'):
1785
- if text_input:
1786
- completion = client.chat.completions.create(
1787
- model=MODEL,
1788
- messages=st.session_state.messages
1789
- )
1790
- return_text = completion.choices[0].message.content
1791
- st.write("Assistant: " + return_text)
1792
- filename = generate_filename(text_input, "md")
1793
- create_file(filename, text_input, return_text, should_save)
1794
- return return_text
1795
 
1796
 
1797
  # st.title("GPT-4o ChatBot")
@@ -1811,19 +1729,14 @@ for message in st.session_state.messages:
1811
  current_messages.append(message)
1812
  st.markdown(message["content"])
1813
 
 
1814
  if prompt := st.chat_input("GPT-4o Multimodal ChatBot - What can I help you with?"):
1815
  st.session_state.messages.append({"role": "user", "content": prompt})
1816
-
1817
  with st.chat_message("user"):
1818
  st.markdown(prompt)
1819
-
1820
  with st.chat_message("assistant"):
1821
  completion = client.chat.completions.create(
1822
  model=MODEL,
1823
- #messages=[
1824
- # {"role": m["role"], "content": m["content"]}
1825
- # for m in st.session_state.messages
1826
- #],
1827
  messages = st.session_state.messages,
1828
  stream=True
1829
  )
 
1335
  )
1336
  st.write(result)
1337
  return result
1338
+
1339
+ # ChatBot client chat completions ------------------------- !!
1340
+ def process_text2(MODEL='gpt-4o-2024-05-13', text_input='What is 2+2 and what is an imaginary number'):
1341
+ if text_input:
1342
+ completion = client.chat.completions.create(
1343
+ model=MODEL,
1344
+ messages=st.session_state.messages
1345
+ )
1346
+ return_text = completion.choices[0].message.content
1347
+ st.write("Assistant: " + return_text)
1348
+ filename = generate_filename(text_input, "md")
1349
+ create_file(filename, text_input, return_text, should_save)
1350
+ return return_text
1351
+
1352
+ # Transcript to arxiv and client chat completion ------------------------- !!
1353
  filename = save_and_play_audio(audio_recorder)
1354
  if filename is not None:
1355
  transcript=''
 
1356
  transcript=transcribe_canary(filename)
1357
+
1358
+ # Search ArXiV and get the Summary and Reference Papers Listing
1359
  result = search_arxiv(transcript)
 
 
 
1360
 
1361
+ # Start chatbot with transcript:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1362
 
1363
+ # ChatBot Entry
1364
+ MODEL = "gpt-4o-2024-05-13"
1365
+ openai.api_key = os.getenv('OPENAI_API_KEY')
1366
+ openai.organization = os.getenv('OPENAI_ORG_ID')
1367
+ client = OpenAI(api_key= os.getenv('OPENAI_API_KEY'), organization=os.getenv('OPENAI_ORG_ID'))
1368
+ st.session_state.messages.append({"role": "user", "content": transcript})
1369
+ with st.chat_message("user"):
1370
+ st.markdown(transcript)
1371
+ with st.chat_message("assistant"):
1372
+ completion = client.chat.completions.create(
1373
+ model=MODEL,
1374
+ messages = st.session_state.messages,
1375
+ stream=True
1376
+ )
1377
+ response = process_text2(text_input=prompt)
1378
+ st.session_state.messages.append({"role": "assistant", "content": response})
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1379
 
1380
+ # Scholary ArXiV Search ------------------------- !!
1381
  session_state = {}
1382
  if "search_queries" not in session_state:
1383
  session_state["search_queries"] = []
 
1409
  menu = ["txt", "htm", "xlsx", "csv", "md", "py"]
1410
  choice = st.sidebar.selectbox("Output File Type:", menu)
1411
 
 
 
1412
  AddAFileForContext=False
1413
  if AddAFileForContext:
1414
 
 
1710
  display_images_and_wikipedia_summaries(num_columns_images) # Image Jump Grid
1711
 
1712
 
 
 
 
 
 
 
 
 
 
 
 
1713
 
1714
 
1715
  # st.title("GPT-4o ChatBot")
 
1729
  current_messages.append(message)
1730
  st.markdown(message["content"])
1731
 
1732
+ # ChatBot Entry
1733
  if prompt := st.chat_input("GPT-4o Multimodal ChatBot - What can I help you with?"):
1734
  st.session_state.messages.append({"role": "user", "content": prompt})
 
1735
  with st.chat_message("user"):
1736
  st.markdown(prompt)
 
1737
  with st.chat_message("assistant"):
1738
  completion = client.chat.completions.create(
1739
  model=MODEL,
 
 
 
 
1740
  messages = st.session_state.messages,
1741
  stream=True
1742
  )