Spaces:
Building
Building
Upload 4 files
Browse files
app.py
CHANGED
@@ -47,6 +47,9 @@ class APIKeyManager:
|
|
47 |
def __init__(self):
|
48 |
self.api_keys = os.environ.get('KeyArray').split(',')
|
49 |
self.current_index = 0
|
|
|
|
|
|
|
50 |
|
51 |
def get_available_key(self):
|
52 |
if self.current_index >= len(self.api_keys):
|
@@ -185,8 +188,10 @@ def chat_completions():
|
|
185 |
|
186 |
yield f"data: {json.dumps(data)}\n\n"
|
187 |
except Exception as e:
|
|
|
188 |
logger.error(f"Error during streaming: {str(e)}")
|
189 |
-
|
|
|
190 |
data = {
|
191 |
'error': {
|
192 |
'message': str(e),
|
|
|
47 |
def __init__(self):
|
48 |
self.api_keys = os.environ.get('KeyArray').split(',')
|
49 |
self.current_index = 0
|
50 |
+
logger.info(f"API Keys: {len(self.api_keys)} found")
|
51 |
+
for i, api_key in enumerate(self.api_keys):
|
52 |
+
logger.info(f"API Key{i}: {api_key[:11]}...")
|
53 |
|
54 |
def get_available_key(self):
|
55 |
if self.current_index >= len(self.api_keys):
|
|
|
188 |
|
189 |
yield f"data: {json.dumps(data)}\n\n"
|
190 |
except Exception as e:
|
191 |
+
|
192 |
logger.error(f"Error during streaming: {str(e)}")
|
193 |
+
current_api_key = key_manager.get_available_key()
|
194 |
+
logger.info(f"API KEY Switched -> {current_api_key[:11]}...")
|
195 |
data = {
|
196 |
'error': {
|
197 |
'message': str(e),
|