devin-ai commited on
Commit
6486389
1 Parent(s): 361788f

remove global variable

Browse files
Files changed (1) hide show
  1. main.py +8 -6
main.py CHANGED
@@ -252,7 +252,7 @@ def extract_transcript(youtube_link):
252
 
253
  # async def clean_up_cache():
254
  # while True:
255
- # await asyncio.sleep(1000) # Check cache every 60 seconds
256
 
257
  # current_time = time.time()
258
  # expired_keys = [key for key, value in cache.items() if current_time - value["timestamp"] > 300]
@@ -296,10 +296,11 @@ async def test():
296
 
297
 
298
  @app.post("/webqa")
299
- async def webchat(question:str):
300
- global content
301
  try:
302
- if content:
 
303
  response=model.generate_content([prompt4,content,question])
304
  print(response.text)
305
  return response.text
@@ -326,9 +327,10 @@ async def ytranscript(url : str):
326
 
327
 
328
  @app.post("/ytqanda")
329
- async def ytchat(question:str):
330
- global transcript
331
  try:
 
332
  if transcript:
333
  response=model.generate_content([prompt4,transcript,question])
334
  print(response.text)
 
252
 
253
  # async def clean_up_cache():
254
  # while True:
255
+ # await asyncio.sleep(1000) # Check cache every 60 seconds abhi
256
 
257
  # current_time = time.time()
258
  # expired_keys = [key for key, value in cache.items() if current_time - value["timestamp"] > 300]
 
296
 
297
 
298
  @app.post("/webqa")
299
+ async def webchat(url: str , question: str):
300
+ # global content
301
  try:
302
+ status,content=scrweb(url)
303
+ if status==200:
304
  response=model.generate_content([prompt4,content,question])
305
  print(response.text)
306
  return response.text
 
327
 
328
 
329
  @app.post("/ytqanda")
330
+ async def ytchat(url: str , question: str):
331
+ # global transcript
332
  try:
333
+ transcript=extract_transcript(url)
334
  if transcript:
335
  response=model.generate_content([prompt4,transcript,question])
336
  print(response.text)