awacke1 commited on
Commit
cda10bd
ยท
verified ยท
1 Parent(s): 25e0d92

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -153,12 +153,11 @@ def create_file(prompt, response, file_type="md"):
153
  return filename
154
 
155
  def get_download_link(file, file_type="mp3"):
156
- # โฌ‡๏ธ Cached download link - Fixed Unicode issue!
157
  cache_key = f"dl_{file}"
158
  if cache_key not in st.session_state['download_link_cache']:
159
  with open(file, "rb") as f:
160
  b64 = base64.b64encode(f.read()).decode()
161
- # Swapped โฌ‡๏ธ with "Download" for safety
162
  st.session_state['download_link_cache'][cache_key] = f'<a href="data:audio/mpeg;base64,{b64}" download="{os.path.basename(file)}">{FILE_EMOJIS.get(file_type, "Download")} Download {os.path.basename(file)}</a>'
163
  return st.session_state['download_link_cache'][cache_key]
164
 
@@ -319,8 +318,8 @@ async def create_paper_audio_files(papers, query):
319
  p['full_audio'], _ = await async_edge_tts_generate(audio_text, st.session_state['tts_voice'])
320
  if p['full_audio']: p['download_base64'] = get_download_link(p['full_audio'])
321
 
322
- def perform_ai_lookup(q, useArxiv=True, useArxivAudio=False):
323
- # ๐Ÿ”ฎ AI-powered research
324
  client = anthropic.Anthropic(api_key=anthropic_key)
325
  response = client.messages.create(model="claude-3-sonnet-20240229", max_tokens=1000, messages=[{"role": "user", "content": q}])
326
  result = response.content[0].text
@@ -423,7 +422,7 @@ async def async_interface():
423
  elif tab_main == "๐Ÿ” ArXiv":
424
  q = st.text_input("๐Ÿ” Query:")
425
  if q and st.button("๐Ÿ” Run"):
426
- result, papers = perform_ai_lookup(q, useArxiv, useArxivAudio)
427
  for i, p in enumerate(papers, 1):
428
  with st.expander(f"{i}. ๐Ÿ“„ {p['title']}"):
429
  st.markdown(f"**{p['date']} | {p['title']}** โ€” [Link]({p['url']})")
 
153
  return filename
154
 
155
  def get_download_link(file, file_type="mp3"):
156
+ # โฌ‡๏ธ Cached download link
157
  cache_key = f"dl_{file}"
158
  if cache_key not in st.session_state['download_link_cache']:
159
  with open(file, "rb") as f:
160
  b64 = base64.b64encode(f.read()).decode()
 
161
  st.session_state['download_link_cache'][cache_key] = f'<a href="data:audio/mpeg;base64,{b64}" download="{os.path.basename(file)}">{FILE_EMOJIS.get(file_type, "Download")} Download {os.path.basename(file)}</a>'
162
  return st.session_state['download_link_cache'][cache_key]
163
 
 
318
  p['full_audio'], _ = await async_edge_tts_generate(audio_text, st.session_state['tts_voice'])
319
  if p['full_audio']: p['download_base64'] = get_download_link(p['full_audio'])
320
 
321
+ async def perform_ai_lookup(q, useArxiv=True, useArxivAudio=False):
322
+ # ๐Ÿ”ฎ AI-powered research (now async!)
323
  client = anthropic.Anthropic(api_key=anthropic_key)
324
  response = client.messages.create(model="claude-3-sonnet-20240229", max_tokens=1000, messages=[{"role": "user", "content": q}])
325
  result = response.content[0].text
 
422
  elif tab_main == "๐Ÿ” ArXiv":
423
  q = st.text_input("๐Ÿ” Query:")
424
  if q and st.button("๐Ÿ” Run"):
425
+ result, papers = await perform_ai_lookup(q, useArxiv, useArxivAudio) # Now async!
426
  for i, p in enumerate(papers, 1):
427
  with st.expander(f"{i}. ๐Ÿ“„ {p['title']}"):
428
  st.markdown(f"**{p['date']} | {p['title']}** โ€” [Link]({p['url']})")