Skip to content

Commit

Permalink
add migration guide
Browse files Browse the repository at this point in the history
  • Loading branch information
vachillo committed Aug 26, 2024
1 parent f9881d0 commit 5a9ab50
Showing 1 changed file with 65 additions and 2 deletions.
67 changes: 65 additions & 2 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,79 @@ This document provides instructions for migrating your codebase to accommodate b
Drivers, Loaders, and Engines will now raises exceptions rather than returning `ErrorArtifact`s.
Update any logic that expects `ErrorArtifact` to handle exceptions instead.

#### 0.30.X
```python
# Before
artifacts = WebLoader().load("https://www.griptape.ai")

if isinstance(artifacts, ErrorArtifact):
raise Exception(artifacts.value)
```

# After
#### 0.31.X
```python
try:
artifacts = WebLoader().load("https://www.griptape.ai")
except Exception as e:
raise e
```

### Changes to BaseConversationMemoryDriver

`BaseConversationMemoryDriver` has updated parameter names and different method signatures for `.store` and `.load`.

#### 0.30.X
```python
memory_driver = LocalConversationMemoryDriver()

conversation_memory = ConversationMemory(
driver=memory_driver
)

load_result: BaseConversationMemory = memory_driver.load()

memory_driver.store(conversation_memory)
```

#### 0.31.X
```python
memory_driver = LocalConversationMemoryDriver()

conversation_memory = ConversationMemory(
conversation_memory_driver=memory_driver
)

load_result: tuple[list[Run], dict[str, Any]] = memory_driver.load()

memory_driver.store(
conversation_memory.runs,
conversation_memory.meta
)
```

### LocalConversationMemoryDriver `file_path` renamed to `persist_file`

`LocalConversationMemoryDriver.file_path` has been renamed to `persist_file` and is now `Optional[str]`. If `persist_file` is not passed as a parameter, nothing will be persisted and no errors will be raised. `LocalConversationMemoryDriver` is now the default driver in the global `Defaults` object.

#### 0.30.X
```python
local_driver_with_file = LocalConversationMemoryDriver(
file_path="my_file.json"
)

local_driver = LocalConversationMemoryDriver()

assert local_driver_with_file.file_path == "my_file.json"
assert local_driver.file_path == "griptape_memory.json"
```

#### 0.31.X
```python
local_driver_with_file = LocalConversationMemoryDriver(
persist_file="my_file.json"
)

local_driver = LocalConversationMemoryDriver()

assert local_driver_with_file.persist_file == "my_file.json"
assert local_driver.persist_file is None
```

0 comments on commit 5a9ab50

Please sign in to comment.