Skip to content

Commit

Permalink
Merge branch 'dev' into feature/lm-studio-prompt-driver
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter committed Jul 11, 2024
2 parents 4fa3bf3 + 160a4ef commit 2d4d889
Show file tree
Hide file tree
Showing 125 changed files with 452 additions and 279 deletions.
4 changes: 1 addition & 3 deletions griptape/artifacts/boolean_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ class BooleanArtifact(BaseArtifact):

@classmethod
def parse_bool(cls, value: Union[str, bool]) -> BooleanArtifact:
"""
Convert a string literal or bool to a BooleanArtifact. The string must be either "true" or "false" with any casing.
"""
"""Convert a string literal or bool to a BooleanArtifact. The string must be either "true" or "false" with any casing."""
if value is not None:
if isinstance(value, str):
if value.lower() == "true":
Expand Down
3 changes: 1 addition & 2 deletions griptape/artifacts/media_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

@define
class MediaArtifact(BlobArtifact):
"""MediaArtifact is a type of BlobArtifact that represents media (image, audio, video, etc.)
and can be extended to support a specific media type.
"""MediaArtifact is a type of BlobArtifact that represents media (image, audio, video, etc.) and can be extended to support a specific media type.
Attributes:
value: Raw bytes representing media data.
Expand Down
2 changes: 1 addition & 1 deletion griptape/common/actions/tool_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

from attrs import define, field

from griptape.artifacts import BaseArtifact
from griptape.common import BaseAction

if TYPE_CHECKING:
from griptape.artifacts import BaseArtifact
from griptape.tools import BaseTool


Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from __future__ import annotations

import json
from collections.abc import Sequence

from attrs import define, field

from griptape.common import ToolAction
from griptape.artifacts import ActionArtifact
from griptape.common import BaseDeltaMessageContent, BaseMessageContent, ActionCallDeltaMessageContent
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from collections.abc import Sequence


@define
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from __future__ import annotations

from collections.abc import Sequence

from attrs import define, field

from griptape.artifacts import BaseArtifact
from griptape.common import BaseDeltaMessageContent, BaseMessageContent, ToolAction
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from griptape.artifacts import BaseArtifact
from collections.abc import Sequence


@define
Expand Down
4 changes: 2 additions & 2 deletions griptape/common/prompt_stack/contents/base_message_content.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from __future__ import annotations

from abc import ABC, abstractmethod
from collections.abc import Sequence
from typing import TYPE_CHECKING
from attrs import define, field
from griptape.mixins import SerializableMixin
from .base_delta_message_content import BaseDeltaMessageContent

if TYPE_CHECKING:
from .base_delta_message_content import BaseDeltaMessageContent
from collections.abc import Sequence
from griptape.artifacts.base_artifact import BaseArtifact


Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from __future__ import annotations

from collections.abc import Sequence

from attrs import define, field

from griptape.artifacts import ImageArtifact
from griptape.common import BaseDeltaMessageContent, BaseMessageContent
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from griptape.artifacts import ImageArtifact
from collections.abc import Sequence


@define
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from __future__ import annotations

from attrs import define, field
from collections.abc import Sequence

from griptape.artifacts import TextArtifact
from griptape.common import BaseMessageContent, BaseDeltaMessageContent, TextDeltaMessageContent
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from collections.abc import Sequence


@define
Expand Down
6 changes: 4 additions & 2 deletions griptape/common/prompt_stack/messages/base_message.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from __future__ import annotations

from abc import ABC
from typing import Optional, Union
from typing import Optional, Union, TYPE_CHECKING
from attrs import Factory, define, field


from griptape.common import BaseMessageContent, BaseDeltaMessageContent
from griptape.mixins import SerializableMixin

if TYPE_CHECKING:
from griptape.common import BaseMessageContent, BaseDeltaMessageContent


@define
class BaseMessage(ABC, SerializableMixin):
Expand Down
6 changes: 4 additions & 2 deletions griptape/common/prompt_stack/messages/delta_message.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from __future__ import annotations

from typing import Optional
from typing import Optional, TYPE_CHECKING

from attrs import define, field

from griptape.common import BaseDeltaMessageContent

from .base_message import BaseMessage

if TYPE_CHECKING:
from griptape.common import BaseDeltaMessageContent


@define
class DeltaMessage(BaseMessage):
Expand Down
24 changes: 13 additions & 11 deletions griptape/config/base_structure_config.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
from __future__ import annotations

from abc import ABC
from typing import Optional
from typing import Optional, TYPE_CHECKING

from attrs import define, field

from griptape.config import BaseConfig
from griptape.drivers import (
BaseConversationMemoryDriver,
BaseEmbeddingDriver,
BaseImageGenerationDriver,
BaseImageQueryDriver,
BasePromptDriver,
BaseVectorStoreDriver,
BaseTextToSpeechDriver,
BaseAudioTranscriptionDriver,
)
from griptape.utils import dict_merge

if TYPE_CHECKING:
from griptape.drivers import (
BaseConversationMemoryDriver,
BaseEmbeddingDriver,
BaseImageGenerationDriver,
BaseImageQueryDriver,
BasePromptDriver,
BaseVectorStoreDriver,
BaseTextToSpeechDriver,
BaseAudioTranscriptionDriver,
)


@define
class BaseStructureConfig(BaseConfig, ABC):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

from attrs import define, field

from griptape.artifacts import TextArtifact, AudioArtifact
from griptape.events import StartAudioTranscriptionEvent, FinishAudioTranscriptionEvent
from griptape.mixins import ExponentialBackoffMixin, SerializableMixin

if TYPE_CHECKING:
from griptape.artifacts import TextArtifact, AudioArtifact
from griptape.structures import Structure


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
from attrs import define, field, Factory
from griptape.drivers import BaseEmbeddingDriver
from griptape.tokenizers.amazon_bedrock_tokenizer import AmazonBedrockTokenizer
from griptape.tokenizers.base_tokenizer import BaseTokenizer
from griptape.utils import import_optional_dependency

if TYPE_CHECKING:
from griptape.tokenizers.base_tokenizer import BaseTokenizer
import boto3


@define
class AmazonBedrockCohereEmbeddingDriver(BaseEmbeddingDriver):
"""
"""Amazon Bedrock Cohere Embedding Driver.
Attributes:
model: Embedding model name. Defaults to DEFAULT_MODEL.
input_type: Defaults to `search_query`. Prepends special tokens to differentiate each type from one another:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
from attrs import define, field, Factory
from griptape.drivers import BaseEmbeddingDriver
from griptape.tokenizers.amazon_bedrock_tokenizer import AmazonBedrockTokenizer
from griptape.tokenizers.base_tokenizer import BaseTokenizer
from griptape.utils import import_optional_dependency

if TYPE_CHECKING:
from griptape.tokenizers.base_tokenizer import BaseTokenizer
import boto3


@define
class AmazonBedrockTitanEmbeddingDriver(BaseEmbeddingDriver):
"""
"""Amazon Bedrock Titan Embedding Driver.
Attributes:
model: Embedding model name. Defaults to DEFAULT_MODEL.
tokenizer: Optionally provide custom `BedrockTitanTokenizer`.
Expand Down
3 changes: 2 additions & 1 deletion griptape/drivers/embedding/azure_openai_embedding_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

@define
class AzureOpenAiEmbeddingDriver(OpenAiEmbeddingDriver):
"""
"""Azure OpenAi Embedding Driver.
Attributes:
azure_deployment: An optional Azure OpenAi deployment id. Defaults to the model name.
azure_endpoint: An Azure OpenAi endpoint.
Expand Down
11 changes: 7 additions & 4 deletions griptape/drivers/embedding/base_embedding_driver.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
from __future__ import annotations
import numpy as np
from typing import Optional
from typing import Optional, TYPE_CHECKING
from abc import ABC, abstractmethod
from attrs import define, field
from griptape.artifacts import TextArtifact
from griptape.mixins import ExponentialBackoffMixin
from griptape.tokenizers import BaseTokenizer
from griptape.chunkers import BaseChunker, TextChunker
from griptape.mixins import SerializableMixin

if TYPE_CHECKING:
from griptape.artifacts import TextArtifact
from griptape.tokenizers import BaseTokenizer


@define
class BaseEmbeddingDriver(SerializableMixin, ExponentialBackoffMixin, ABC):
"""
"""Base Embedding Driver.
Attributes:
model: The name of the model to use.
tokenizer: An instance of `BaseTokenizer` to use when calculating tokens.
Expand Down
3 changes: 2 additions & 1 deletion griptape/drivers/embedding/cohere_embedding_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

@define
class CohereEmbeddingDriver(BaseEmbeddingDriver):
"""
"""Cohere Embedding Driver.
Attributes:
api_key: Cohere API key.
model: Cohere model name.
Expand Down
3 changes: 2 additions & 1 deletion griptape/drivers/embedding/google_embedding_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

@define
class GoogleEmbeddingDriver(BaseEmbeddingDriver):
"""
"""Google Embedding Driver.
Attributes:
api_key: Google API key.
model: Google model name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

@define
class HuggingFaceHubEmbeddingDriver(BaseEmbeddingDriver):
"""
"""Hugging Face Hub Embedding Driver.
Attributes:
api_token: Hugging Face Hub API token.
model: Hugging Face Hub model name.
Expand Down
3 changes: 2 additions & 1 deletion griptape/drivers/embedding/ollama_embedding_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

@define
class OllamaEmbeddingDriver(BaseEmbeddingDriver):
"""
"""Ollama Embedding Driver.
Attributes:
model: Ollama embedding model name.
host: Optional Ollama host.
Expand Down
3 changes: 2 additions & 1 deletion griptape/drivers/embedding/openai_embedding_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

@define
class OpenAiEmbeddingDriver(BaseEmbeddingDriver):
"""
"""OpenAI Embedding Driver.
Attributes:
model: OpenAI embedding model name. Defaults to `text-embedding-3-small`.
base_url: API URL. Defaults to OpenAI's v1 API URL.
Expand Down
3 changes: 2 additions & 1 deletion griptape/drivers/embedding/voyageai_embedding_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

@define
class VoyageAiEmbeddingDriver(BaseEmbeddingDriver):
"""
"""VoyageAI Embedding Driver.
Attributes:
model: VoyageAI embedding model name. Defaults to `voyage-large-2`.
api_key: API key to pass directly. Defaults to `VOYAGE_API_KEY` environment variable.
Expand Down
6 changes: 4 additions & 2 deletions griptape/drivers/event_listener/base_event_listener_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
from abc import ABC, abstractmethod
from concurrent import futures
from logging import Logger
from typing import Callable
from typing import Callable, TYPE_CHECKING
from attrs import Factory, define, field
from griptape.events import BaseEvent

if TYPE_CHECKING:
from griptape.events import BaseEvent

logger = Logger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

@define
class AmazonS3FileManagerDriver(BaseFileManagerDriver):
"""
AmazonS3FileManagerDriver can be used to list, load, and save files in an Amazon S3 bucket.
"""AmazonS3FileManagerDriver can be used to list, load, and save files in an Amazon S3 bucket.
Attributes:
session: The boto3 session to use for S3 operations.
Expand Down
3 changes: 1 addition & 2 deletions griptape/drivers/file_manager/base_file_manager_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

@define
class BaseFileManagerDriver(ABC):
"""
BaseFileManagerDriver can be used to list, load, and save files.
"""BaseFileManagerDriver can be used to list, load, and save files.
Attributes:
default_loader: The default loader to use for loading file contents into artifacts.
Expand Down
3 changes: 1 addition & 2 deletions griptape/drivers/file_manager/local_file_manager_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

@define
class LocalFileManagerDriver(BaseFileManagerDriver):
"""
LocalFileManagerDriver can be used to list, load, and save files on the local file system.
"""LocalFileManagerDriver can be used to list, load, and save files on the local file system.
Attributes:
workdir: The absolute working directory. List, load, and save operations will be performed relative to this directory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

from attrs import define, field

from griptape.artifacts import ImageArtifact
from griptape.events import StartImageGenerationEvent, FinishImageGenerationEvent
from griptape.mixins import ExponentialBackoffMixin, SerializableMixin

if TYPE_CHECKING:
from griptape.artifacts import ImageArtifact
from griptape.structures import Structure


Expand Down
Loading

0 comments on commit 2d4d889

Please sign in to comment.