Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -272,6 +272,10 @@ Category: [One category]
|
|
272 |
bookmark['category'] = 'Reference and Knowledge Bases'
|
273 |
|
274 |
logger.info("Successfully generated summary and assigned category")
|
|
|
|
|
|
|
|
|
275 |
break # Exit loop on success
|
276 |
|
277 |
except openai.error.RateLimitError as e:
|
@@ -507,12 +511,12 @@ def process_uploaded_file(file, state_bookmarks):
|
|
507 |
|
508 |
# Fetch bookmark info concurrently
|
509 |
logger.info("Fetching URL info concurrently")
|
510 |
-
with ThreadPoolExecutor(max_workers=
|
511 |
executor.map(fetch_url_info, bookmarks)
|
512 |
|
513 |
# Generate summaries and assign categories
|
514 |
logger.info("Generating summaries and assigning categories")
|
515 |
-
with ThreadPoolExecutor(max_workers=
|
516 |
executor.map(generate_summary_and_assign_category, bookmarks)
|
517 |
|
518 |
# Log bookmarks to verify 'summary' and 'category' presence
|
@@ -731,6 +735,10 @@ Provide a concise and helpful response.
|
|
731 |
)
|
732 |
answer = response['choices'][0]['message']['content'].strip()
|
733 |
logger.info("Chatbot response generated")
|
|
|
|
|
|
|
|
|
734 |
return chat_history + [{"role": "user", "content": user_query}, {"role": "assistant", "content": answer}]
|
735 |
except openai.error.RateLimitError as e:
|
736 |
retry_count += 1
|
|
|
272 |
bookmark['category'] = 'Reference and Knowledge Bases'
|
273 |
|
274 |
logger.info("Successfully generated summary and assigned category")
|
275 |
+
|
276 |
+
# **Introduce Fixed Delay After API Call**
|
277 |
+
time.sleep(1) # Wait for 1 second before the next API call
|
278 |
+
|
279 |
break # Exit loop on success
|
280 |
|
281 |
except openai.error.RateLimitError as e:
|
|
|
511 |
|
512 |
# Fetch bookmark info concurrently
|
513 |
logger.info("Fetching URL info concurrently")
|
514 |
+
with ThreadPoolExecutor(max_workers=3) as executor: # Adjusted max_workers to 3
|
515 |
executor.map(fetch_url_info, bookmarks)
|
516 |
|
517 |
# Generate summaries and assign categories
|
518 |
logger.info("Generating summaries and assigning categories")
|
519 |
+
with ThreadPoolExecutor(max_workers=1) as executor: # Adjusted max_workers to 1
|
520 |
executor.map(generate_summary_and_assign_category, bookmarks)
|
521 |
|
522 |
# Log bookmarks to verify 'summary' and 'category' presence
|
|
|
735 |
)
|
736 |
answer = response['choices'][0]['message']['content'].strip()
|
737 |
logger.info("Chatbot response generated")
|
738 |
+
|
739 |
+
# **Introduce Fixed Delay After API Call**
|
740 |
+
time.sleep(1) # Wait for 1 second before the next API call
|
741 |
+
|
742 |
return chat_history + [{"role": "user", "content": user_query}, {"role": "assistant", "content": answer}]
|
743 |
except openai.error.RateLimitError as e:
|
744 |
retry_count += 1
|