refac
This commit is contained in:
1 parent
0ffc04797f
commit
21f9e5295b
1 file changed
+9
-2
+9
-2
@@ -443,11 +443,18 @@ LEGACY_KEY_TO_STORAGE_KEY = {
|
|||||||
|
|
||||||
|
|
||||||
def _walk_blob(data: dict, prefix: str = '') -> dict:
|
def _walk_blob(data: dict, prefix: str = '') -> dict:
|
||||||
"""Recursively walk a nested dict, yielding (dot.path, value) for leaf nodes."""
|
"""Recursively walk a nested config blob, preserving known config values.
|
||||||
|
|
||||||
|
Some config values are intentionally dictionaries, e.g. OPENAI_API_CONFIGS
|
||||||
|
and OLLAMA_API_CONFIGS. Once the current path is a known config key, keep
|
||||||
|
that value intact instead of flattening its internals into orphaned rows.
|
||||||
|
"""
|
||||||
result = {}
|
result = {}
|
||||||
for key, value in data.items():
|
for key, value in data.items():
|
||||||
path = f'{prefix}{key}' if not prefix else f'{prefix}.{key}'
|
path = f'{prefix}{key}' if not prefix else f'{prefix}.{key}'
|
||||||
if isinstance(value, dict):
|
if path in BLOB_PATH_TO_KEY or path in LEGACY_KEY_TO_STORAGE_KEY:
|
||||||
|
result[path] = value
|
||||||
|
elif isinstance(value, dict):
|
||||||
result.update(_walk_blob(value, path))
|
result.update(_walk_blob(value, path))
|
||||||
else:
|
else:
|
||||||
result[path] = value
|
result[path] = value
|
||||||
|
|||||||
Reference in new issue
Block a user