From 7a4735123b168c9380051e8d8a158c77640297a5 Mon Sep 17 00:00:00 2001 From: Collin Dutter Date: Tue, 22 Oct 2024 08:41:32 -0700 Subject: [PATCH 1/2] Remove voyageai from anthropic drivers config --- CHANGELOG.md | 1 + MIGRATION.md | 36 ++++++++++++++++++- docs/griptape-framework/structures/configs.md | 1 - .../drivers/anthropic_drivers_config.py | 10 ------ .../drivers/test_anthropic_drivers_config.py | 10 ++---- 5 files changed, 39 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a6fb04d2..d38286dcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - If `EventListener.handler` returns `None`, the event will not be published to the `event_listener_driver`. - If `EventListener.handler` is None, the event will be published to the `event_listener_driver` as-is. - **BREAKING**: Moved `griptape.common.observable.observable` to `griptape.common.decorators.observable`. +- **BREAKING**: `AnthropicDriversConfig` no longer bundles `VoyageAiEmbeddingDriver`. - Updated `EventListener.handler` return type to `Optional[BaseEvent | dict]`. - `BaseTask.parent_outputs` type has changed from `dict[str, str | None]` to `dict[str, BaseArtifact]`. - `Workflow.context["parent_outputs"]` type has changed from `dict[str, str | None]` to `dict[str, BaseArtifact]`. diff --git a/MIGRATION.md b/MIGRATION.md index 41b501870..60af11fc9 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -2,6 +2,40 @@ This document provides instructions for migrating your codebase to accommodate breaking changes introduced in new versions of Griptape. +## 0.34.X to 0.35.X + +### `AnthropicDriversConfig` Embedding Driver + +`AnthropicDriversConfig` no longer bundles `VoyageAiEmbeddingDriver`. If you rely on embeddings when using Anthropic, you must specify an Embedding Driver yourself. + +#### Before + +```python +from griptape.configs import Defaults +from griptape.configs.drivers import AnthropicDriversConfig +from griptape.structures import Agent + +Defaults.drivers_config = AnthropicDriversConfig() + +agent = Agent() +``` + +#### After + +````python +from griptape.configs import Defaults +from griptape.configs.drivers import AnthropicDriversConfig +from griptape.drivers import VoyageAiEmbeddingDriver, LocalVectorStoreDriver + +Defaults.drivers_config = AnthropicDriversConfig( + embedding_driver=VoyageAiEmbeddingDriver(), + vector_store_driver=LocalVectorStoreDriver( + embedding_driver=VoyageAiEmbeddingDriver() + ) +) +``` + + ## 0.33.X to 0.34.X ### Removed `CompletionChunkEvent` @@ -21,7 +55,7 @@ def handler_fn_stream_text(event: CompletionChunkEvent) -> None: EventListener(handler=handler_fn_stream, event_types=[CompletionChunkEvent]) EventListener(handler=handler_fn_stream_text, event_types=[CompletionChunkEvent]) -``` +```` #### After diff --git a/docs/griptape-framework/structures/configs.md b/docs/griptape-framework/structures/configs.md index 98c58985d..fa72a1314 100644 --- a/docs/griptape-framework/structures/configs.md +++ b/docs/griptape-framework/structures/configs.md @@ -64,7 +64,6 @@ The [Anthropic Driver config](../../reference/griptape/configs/drivers/anthropic !!! info Anthropic does not provide an embeddings API which means you will need to use another service for embeddings. - The `AnthropicDriversConfig` defaults to using `VoyageAiEmbeddingDriver` which integrates with [VoyageAI](https://www.voyageai.com/), the service used in Anthropic's [embeddings documentation](https://docs.anthropic.com/claude/docs/embeddings). To override the default embedding driver, see: [Override Default Structure Embedding Driver](../drivers/embedding-drivers.md#override-default-structure-embedding-driver). ```python diff --git a/griptape/configs/drivers/anthropic_drivers_config.py b/griptape/configs/drivers/anthropic_drivers_config.py index e5a1f2719..6a0fa52d4 100644 --- a/griptape/configs/drivers/anthropic_drivers_config.py +++ b/griptape/configs/drivers/anthropic_drivers_config.py @@ -4,8 +4,6 @@ from griptape.drivers import ( AnthropicImageQueryDriver, AnthropicPromptDriver, - LocalVectorStoreDriver, - VoyageAiEmbeddingDriver, ) from griptape.utils.decorators import lazy_property @@ -16,14 +14,6 @@ class AnthropicDriversConfig(DriversConfig): def prompt_driver(self) -> AnthropicPromptDriver: return AnthropicPromptDriver(model="claude-3-5-sonnet-20240620") - @lazy_property() - def embedding_driver(self) -> VoyageAiEmbeddingDriver: - return VoyageAiEmbeddingDriver(model="voyage-large-2") - - @lazy_property() - def vector_store_driver(self) -> LocalVectorStoreDriver: - return LocalVectorStoreDriver(embedding_driver=VoyageAiEmbeddingDriver(model="voyage-large-2")) - @lazy_property() def image_query_driver(self) -> AnthropicImageQueryDriver: return AnthropicImageQueryDriver(model="claude-3-5-sonnet-20240620") diff --git a/tests/unit/configs/drivers/test_anthropic_drivers_config.py b/tests/unit/configs/drivers/test_anthropic_drivers_config.py index b69893560..bfc5b06f9 100644 --- a/tests/unit/configs/drivers/test_anthropic_drivers_config.py +++ b/tests/unit/configs/drivers/test_anthropic_drivers_config.py @@ -33,16 +33,12 @@ def test_to_dict(self, config): "max_tokens": 256, }, "embedding_driver": { - "type": "VoyageAiEmbeddingDriver", - "model": "voyage-large-2", - "input_type": "document", + "type": "DummyEmbeddingDriver", }, "vector_store_driver": { - "type": "LocalVectorStoreDriver", + "type": "DummyVectorStoreDriver", "embedding_driver": { - "type": "VoyageAiEmbeddingDriver", - "model": "voyage-large-2", - "input_type": "document", + "type": "DummyEmbeddingDriver", }, }, "conversation_memory_driver": { From d7a7ad9bb4031a2a50d3001da6dc5db62ecaa1ec Mon Sep 17 00:00:00 2001 From: Collin Dutter Date: Wed, 23 Oct 2024 09:52:22 -0700 Subject: [PATCH 2/2] Remove extra ticks --- MIGRATION.md | 4 ++-- docs/griptape-tools/official-tools/prompt-summary-tool.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index 60af11fc9..74c83c347 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -22,7 +22,7 @@ agent = Agent() #### After -````python +```python from griptape.configs import Defaults from griptape.configs.drivers import AnthropicDriversConfig from griptape.drivers import VoyageAiEmbeddingDriver, LocalVectorStoreDriver @@ -55,7 +55,7 @@ def handler_fn_stream_text(event: CompletionChunkEvent) -> None: EventListener(handler=handler_fn_stream, event_types=[CompletionChunkEvent]) EventListener(handler=handler_fn_stream_text, event_types=[CompletionChunkEvent]) -```` +``` #### After diff --git a/docs/griptape-tools/official-tools/prompt-summary-tool.md b/docs/griptape-tools/official-tools/prompt-summary-tool.md index 23c35c367..e2b4c49ec 100644 --- a/docs/griptape-tools/official-tools/prompt-summary-tool.md +++ b/docs/griptape-tools/official-tools/prompt-summary-tool.md @@ -4,7 +4,7 @@ The [PromptSummaryTool](../../reference/griptape/tools/prompt_summary/tool.md) e --8<-- "docs/griptape-tools/official-tools/src/prompt_summary_tool_1.py" ``` -```` +``` [08/12/24 15:54:46] INFO ToolkitTask 8be73eb542c44418ba880399044c017a Input: How can I build Neovim from source for MacOS according to this https://github.com/neovim/neovim/blob/master/BUILD.md [08/12/24 15:54:47] INFO Subtask cd362a149e1d400997be93c1342d1663 @@ -103,4 +103,4 @@ The [PromptSummaryTool](../../reference/griptape/tools/prompt_summary/tool.md) e By following these steps, you should be able to build and install Neovim from source on macOS. For more detailed instructions and troubleshooting tips, refer to the [BUILD.md](https://github.com/neovim/neovim/blob/master/BUILD.md) file in the Neovim repository. -```` +```