awacke1 commited on
Commit
1f36af1
·
verified ·
1 Parent(s): 9ce596c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +86 -0
app.py CHANGED
@@ -366,10 +366,88 @@ def parse_arxiv_refs(ref_text: str):
366
 
367
  return results[:20]
368
 
 
 
 
 
369
  def perform_ai_lookup(q, vocal_summary=True, extended_refs=False,
370
  titles_summary=True, full_audio=False):
371
  start = time.time()
372
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
373
  client = Client("awacke1/Arxiv-Paper-Search-And-QA-RAG-Pattern")
374
  refs = client.predict(q, 20, "Semantic Search",
375
  "mistralai/Mixtral-8x7B-Instruct-v0.1",
@@ -377,6 +455,8 @@ def perform_ai_lookup(q, vocal_summary=True, extended_refs=False,
377
  r2 = client.predict(q, "mistralai/Mixtral-8x7B-Instruct-v0.1",
378
  True, api_name="/ask_llm")
379
 
 
 
380
  result = f"### 🔎 {q}\n\n{r2}\n\n{refs}"
381
  st.markdown(result)
382
 
@@ -394,6 +474,12 @@ def perform_ai_lookup(q, vocal_summary=True, extended_refs=False,
394
 
395
  elapsed = time.time()-start
396
  st.write(f"**Total Elapsed:** {elapsed:.2f} s")
 
 
 
 
 
 
397
  return result
398
 
399
  def process_voice_input(text):
 
366
 
367
  return results[:20]
368
 
369
+
370
+
371
+ # ----------------------------
372
+
373
  def perform_ai_lookup(q, vocal_summary=True, extended_refs=False,
374
  titles_summary=True, full_audio=False):
375
  start = time.time()
376
 
377
+ SCIENCE_PROBLEM = "Solving visual acuity of UI screens using gradio and streamlit apps that run reactive style components using html components and apis across gradio and streamlit partner apps - a cloud of contiguous org supporting ai agents"
378
+ SONG_STYLE = "techno, trance, industrial"
379
+
380
+
381
+ ai_constitution = """
382
+
383
+ You are a talented songwriter with a unique ability to explain scientific concepts through music. Your task is to create a song that not only entertains but also educates listeners about a specific science problem and its potential solutions.
384
+
385
+ First, carefully read and analyze the science problem provided:
386
+
387
+ <science_problem>
388
+ {{SCIENCE_PROBLEM}}
389
+ </science_problem>
390
+
391
+ Next, consider the song style requested:
392
+
393
+ <song_style>
394
+ {{SONG_STYLE}}
395
+ </song_style>
396
+
397
+ Follow these steps to create your song:
398
+
399
+ 1. Analyze the science problem:
400
+ - Identify the key issues and challenges
401
+ - Note any potential solutions or technologies mentioned
402
+ - Consider how these concepts can be simplified for a general audience
403
+
404
+ 2. Plan your song structure:
405
+ - Decide on a verse-chorus format that fits the song style
406
+ - Plan to introduce the problem in the verses
407
+ - Use the chorus to highlight key points or solutions
408
+
409
+ 3. Write your lyrics:
410
+ - Begin with an attention-grabbing opening line
411
+ - Use metaphors and analogies to explain complex concepts
412
+ - Ensure the lyrics flow naturally and fit the rhythm of the chosen song style
413
+ - Include scientific terminology, but explain it in simple terms within the song
414
+
415
+ 4. Incorporate scientific explanations:
416
+ - Weave factual information throughout the verses
417
+ - Use the chorus to reinforce main ideas or solutions
418
+ - Ensure that the scientific content is accurate and up-to-date
419
+
420
+ 5. Match the requested song style:
421
+ - Adapt your word choice and phrasing to fit the genre
422
+ - Consider the typical rhythm and structure of songs in this style
423
+ - If applicable, include style-specific elements (e.g., a rap break, a power ballad chorus)
424
+
425
+ 6. Review and refine:
426
+ - Check that the song effectively communicates the science problem and solutions
427
+ - Ensure the lyrics are catchy and memorable
428
+ - Verify that the song maintains the requested style throughout
429
+
430
+ Present your final song in the following format:
431
+
432
+ <song>
433
+ <title>[Insert creative title that reflects both the scientific concept and song style]</title>
434
+
435
+ <lyrics>
436
+ [Insert your full song lyrics here, clearly marking verses, chorus, and any other sections]
437
+ </lyrics>
438
+
439
+ <explanation>
440
+ [Provide a brief explanation of how the song addresses the science problem and its solutions, highlighting key scientific concepts included in the lyrics]
441
+ </explanation>
442
+ </song>
443
+
444
+ Remember to balance scientific accuracy with musical creativity, ensuring that your song is both informative and entertaining.
445
+
446
+ """
447
+
448
+
449
+
450
+
451
  client = Client("awacke1/Arxiv-Paper-Search-And-QA-RAG-Pattern")
452
  refs = client.predict(q, 20, "Semantic Search",
453
  "mistralai/Mixtral-8x7B-Instruct-v0.1",
 
455
  r2 = client.predict(q, "mistralai/Mixtral-8x7B-Instruct-v0.1",
456
  True, api_name="/ask_llm")
457
 
458
+
459
+
460
  result = f"### 🔎 {q}\n\n{r2}\n\n{refs}"
461
  st.markdown(result)
462
 
 
474
 
475
  elapsed = time.time()-start
476
  st.write(f"**Total Elapsed:** {elapsed:.2f} s")
477
+
478
+
479
+
480
+
481
+
482
+
483
  return result
484
 
485
  def process_voice_input(text):