Skip to content

Commit

Permalink
Update docs for saving/loading drivers configs
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter committed Dec 16, 2024
1 parent ca39b3b commit 7ebe75f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions docs/griptape-framework/structures/configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ agent.run("Hello world!")

### Loading/Saving Configs

You can serialize and deserialize Driver Configs using the [to_json()][../../reference/griptape/mixins/serializable_mixin.md#griptape.mixins.serializable_mixin.SerializableMixin.to_json] and [from_json()](../../reference/griptape/mixins/serializable_mixin.md#griptape.mixins.serializable_mixin.SerializableMixin.from_json) methods.

```python
--8<-- "docs/griptape-framework/structures/src/drivers_config_8.py"
```
24 changes: 12 additions & 12 deletions docs/griptape-framework/structures/src/drivers_config_8.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from pathlib import Path

from griptape.configs import Defaults
from griptape.configs.drivers import AmazonBedrockDriversConfig
from griptape.configs.drivers import DriversConfig
from griptape.structures import Agent

custom_config = AmazonBedrockDriversConfig()
dict_config = custom_config.to_dict()
# Use OpenAi for embeddings
dict_config["embedding_driver"] = {
"base_url": None,
"model": "text-embedding-3-small",
"organization": None,
"type": "OpenAiEmbeddingDriver",
}
custom_config = AmazonBedrockDriversConfig.from_dict(dict_config)
config_file = "config.json"

# Save config
config_text = Defaults.drivers_config.to_json()
Path(config_file).write_text(config_text)

# Load config
config_text = Path(config_file).read_text()
Defaults.drivers_config = DriversConfig.from_json(config_text)

Defaults.drivers_config = custom_config

agent = Agent()

0 comments on commit 7ebe75f

Please sign in to comment.