Default to all models if model field is not set
Browse files---
For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/yym68686/uni-api?shareId=XXXX-XXXX-XXXX-XXXX).
utils.py
CHANGED
|
@@ -119,6 +119,10 @@ def update_config(config_data, use_config_url=False):
|
|
| 119 |
config_data['api_keys'][index]['weights'] = weights_dict
|
| 120 |
config_data['api_keys'][index]['model'] = models
|
| 121 |
api_keys_db[index]['model'] = models
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
api_list = [item["api"] for item in api_keys_db]
|
| 124 |
# logger.info(json.dumps(config_data, indent=4, ensure_ascii=False))
|
|
@@ -385,4 +389,4 @@ def safe_get(data, *keys, default=None):
|
|
| 385 |
data = data[key] if isinstance(data, (dict, list)) else data.get(key)
|
| 386 |
except (KeyError, IndexError, AttributeError, TypeError):
|
| 387 |
return default
|
| 388 |
-
return data
|
|
|
|
| 119 |
config_data['api_keys'][index]['weights'] = weights_dict
|
| 120 |
config_data['api_keys'][index]['model'] = models
|
| 121 |
api_keys_db[index]['model'] = models
|
| 122 |
+
else:
|
| 123 |
+
# Default to all models if 'model' field is not set
|
| 124 |
+
config_data['api_keys'][index]['model'] = ["all"]
|
| 125 |
+
api_keys_db[index]['model'] = ["all"]
|
| 126 |
|
| 127 |
api_list = [item["api"] for item in api_keys_db]
|
| 128 |
# logger.info(json.dumps(config_data, indent=4, ensure_ascii=False))
|
|
|
|
| 389 |
data = data[key] if isinstance(data, (dict, list)) else data.get(key)
|
| 390 |
except (KeyError, IndexError, AttributeError, TypeError):
|
| 391 |
return default
|
| 392 |
+
return data
|