Spaces:
Running
Running
siddhartharya
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -84,9 +84,9 @@ openai.api_key = OPENAI_API_KEY
|
|
84 |
openai.api_base = "https://api.groq.com/openai/v1" # Ensure this is the correct base URL for your API
|
85 |
|
86 |
# Rate Limiter Configuration
|
87 |
-
RPM_LIMIT = 60
|
88 |
-
TPM_LIMIT = 60000
|
89 |
-
BATCH_SIZE = 5
|
90 |
|
91 |
# Implementing a Token Bucket Rate Limiter
|
92 |
class TokenBucket:
|
@@ -271,7 +271,9 @@ def llm_worker():
|
|
271 |
for idx, bookmark in enumerate(batch, 1):
|
272 |
prompt += f"Bookmark {idx}:\nURL: {bookmark['url']}\nTitle: {bookmark['title']}\n\n"
|
273 |
|
|
|
274 |
prompt += f"Categories:\n{', '.join([f'\"{cat}\"' for cat in CATEGORIES])}\n\n"
|
|
|
275 |
prompt += "Format your response as a JSON object where each key is the bookmark URL and the value is another JSON object containing 'summary' and 'category'.\n\n"
|
276 |
prompt += "Example:\n"
|
277 |
prompt += "{\n"
|
|
|
84 |
openai.api_base = "https://api.groq.com/openai/v1" # Ensure this is the correct base URL for your API
|
85 |
|
86 |
# Rate Limiter Configuration
|
87 |
+
RPM_LIMIT = 60 # Requests per minute (adjust based on your API's limit)
|
88 |
+
TPM_LIMIT = 60000 # Tokens per minute (adjust based on your API's limit)
|
89 |
+
BATCH_SIZE = 5 # Number of bookmarks per batch
|
90 |
|
91 |
# Implementing a Token Bucket Rate Limiter
|
92 |
class TokenBucket:
|
|
|
271 |
for idx, bookmark in enumerate(batch, 1):
|
272 |
prompt += f"Bookmark {idx}:\nURL: {bookmark['url']}\nTitle: {bookmark['title']}\n\n"
|
273 |
|
274 |
+
# Corrected f-string without backslashes
|
275 |
prompt += f"Categories:\n{', '.join([f'\"{cat}\"' for cat in CATEGORIES])}\n\n"
|
276 |
+
|
277 |
prompt += "Format your response as a JSON object where each key is the bookmark URL and the value is another JSON object containing 'summary' and 'category'.\n\n"
|
278 |
prompt += "Example:\n"
|
279 |
prompt += "{\n"
|