Closed collindutter closed 3 weeks ago
It seems like replacing self.to_dict
with attrs.asdict(self)
could be a solution, but this fails with:
Traceback (most recent call last):
File "/Users/collindutter/Documents/griptape/griptape-playground/src/misc/config-issue.py", line 21, in <module>
config = StructureConfig(
File "/Users/collindutter/Documents/griptape/griptape/griptape/config/base_structure_config.py", line 36, in merge_config
base_config = asdict(self)
File "/Users/collindutter/Documents/griptape/griptape-playground/.venv/lib/python3.9/site-packages/attr/_next_gen.py", line 211, in asdict
return _asdict(
File "/Users/collindutter/Documents/griptape/griptape-playground/.venv/lib/python3.9/site-packages/attr/_funcs.py", line 65, in asdict
rv[a.name] = asdict(
File "/Users/collindutter/Documents/griptape/griptape-playground/.venv/lib/python3.9/site-packages/attr/_funcs.py", line 56, in asdict
v = getattr(inst, a.name)
AttributeError: model
Probably an init=False
problem.
Describe the bug
merge_config
does the following:to_dict
on the config.from_dict
containing the merged config.The problem is that
to_dict
throws away fields withoutserializable: True
metadata such asOpenAiChatPromptDriver.api_key
. Meaning if a non-serializable field is set beforemerge_config
, it is lost on merge.To Reproduce IMPORTANT: Ensure
OPENAI_API_KEY
is not set in environment. Run:Output:
Expected behavior
merge_config
should not throw away already set values.