Skip to content

Commit

Permalink
Format repo
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter committed Oct 9, 2024
1 parent 19e61bf commit 33c8a99
Show file tree
Hide file tree
Showing 74 changed files with 409 additions and 254 deletions.
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

- [ ] I have read and agree to the [contributing guidelines](https://github.com/griptape-ai/griptape#contributing).
- [ ] I have read and agree to the [contributing guidelines](https://github.com/griptape-ai/griptape#contributing).

**Describe the bug**
A clear and concise description of what the bug is.
Expand All @@ -22,8 +21,9 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Version [e.g. 0.5.1]

- OS: \[e.g. iOS\]
- Version \[e.g. 0.5.1\]

**Additional context**
Add any other context about the problem here.
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---

- [ ] I have read and agree to the [contributing guidelines](https://github.com/griptape-ai/griptape#contributing).
- [ ] I have read and agree to the [contributing guidelines](https://github.com/griptape-ai/griptape#contributing).

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
A clear and concise description of what the problem is. Ex. I'm always frustrated when \[...\]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.
Expand Down
197 changes: 133 additions & 64 deletions CHANGELOG.md

Large diffs are not rendered by default.

46 changes: 36 additions & 10 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# Migration Guide

This document provides instructions for migrating your codebase to accommodate breaking changes introduced in new versions of Griptape.

## 0.32.X to 0.33.X

### Removed `torch` extra from `transformers` dependency

The `torch` extra has been removed from the `transformers` dependency. If you require `torch`, install it separately.

#### Before

```bash
pip install griptape[drivers-prompt-huggingface-hub]
```

#### After

```bash
pip install griptape[drivers-prompt-huggingface-hub]
pip install torch
Expand All @@ -36,9 +39,10 @@ audio_media = MediaArtifact(
media_type="audio",
format="wav"
)
```
```

#### After

```python
image_artifact = ImageArtifact(
b"image_data",
Expand All @@ -64,6 +68,7 @@ image_artifact = ImageArtifact(
```

#### After

```python
image_artifact = ImageArtifact(
b"image_data",
Expand All @@ -84,6 +89,7 @@ print(type(artifact.value)) # <class 'dict'>
```

#### After

```python
artifact = TextArtifact("name: John\nage: 30")
print(artifact.value) # name: John\nage: 30
Expand All @@ -92,11 +98,11 @@ print(type(artifact.value)) # <class 'str'>

If you require storing a dictionary as an Artifact, you can use `GenericArtifact` instead.

### `CsvLoader`, `DataframeLoader`, and `SqlLoader` return types
### `CsvLoader`, `DataframeLoader`, and `SqlLoader` return types

`CsvLoader`, `DataframeLoader`, and `SqlLoader` now return a `list[TextArtifact]` instead of `list[CsvRowArtifact]`.

If you require a dictionary, set a custom `formatter_fn` and then parse the text to a dictionary.
If you require a dictionary, set a custom `formatter_fn` and then parse the text to a dictionary.

#### Before

Expand All @@ -108,6 +114,7 @@ print(type(results[0].value)) # <class 'dict'>
```

#### After

```python
results = CsvLoader().load(Path("people.csv").read_text())

Expand All @@ -123,7 +130,7 @@ dict_results = [json.loads(result.value) for result in results]
print(dict_results[0]) # {"name": "John", "age": 30}
print(type(dict_results[0])) # <class 'dict'>
```

### Moved `ImageArtifact.prompt` and `ImageArtifact.model` to `ImageArtifact.meta`

`ImageArtifact.prompt` and `ImageArtifact.model` have been moved to `ImageArtifact.meta`.
Expand All @@ -142,6 +149,7 @@ print(image_artifact.prompt, image_artifact.model) # Generate an image of a cat,
```

#### After

```python
image_artifact = ImageArtifact(
b"image_data",
Expand All @@ -155,13 +163,15 @@ print(image_artifact.meta["prompt"], image_artifact.meta["model"]) # Generate an
Renamed `GriptapeCloudKnowledgeBaseVectorStoreDriver` to `GriptapeCloudVectorStoreDriver`.

#### Before

```python
from griptape.drivers.griptape_cloud_knowledge_base_vector_store_driver import GriptapeCloudKnowledgeBaseVectorStoreDriver

driver = GriptapeCloudKnowledgeBaseVectorStoreDriver(...)
```

#### After

```python
from griptape.drivers.griptape_cloud_vector_store_driver import GriptapeCloudVectorStoreDriver

Expand All @@ -173,13 +183,15 @@ driver = GriptapeCloudVectorStoreDriver(...)
`OpenAiChatPromptDriver.response_format` is now structured as the `openai` SDK accepts it.

#### Before

```python
driver = OpenAiChatPromptDriver(
response_format="json_object"
)
```

#### After

```python
driver = OpenAiChatPromptDriver(
response_format={"type": "json_object"}
Expand All @@ -199,6 +211,7 @@ DataframeLoader().load(df)
```

#### After

```python
# Convert the dataframe to csv bytes and parse it
CsvLoader().parse(bytes(df.to_csv(line_terminator='\r\n', index=False), encoding='utf-8'))
Expand All @@ -209,12 +222,14 @@ CsvLoader().parse(bytes(df.to_csv(line_terminator='\r\n', index=False), encoding
### `TextLoader`, `PdfLoader`, `ImageLoader`, and `AudioLoader` now take a `str | PathLike` instead of `bytes`.

#### Before

```python
PdfLoader().load(Path("attention.pdf").read_bytes())
PdfLoader().load_collection([Path("attention.pdf").read_bytes(), Path("CoT.pdf").read_bytes()])
```

#### After

```python
PdfLoader().load("attention.pdf")
PdfLoader().load_collection([Path("attention.pdf"), "CoT.pdf"])
Expand All @@ -231,7 +246,7 @@ You can now pass the file path directly to the Loader.
PdfLoader().load(load_file("attention.pdf").read_bytes())
PdfLoader().load_collection(list(load_files(["attention.pdf", "CoT.pdf"]).values()))
```

```python
PdfLoader().load("attention.pdf")
PdfLoader().load_collection(["attention.pdf", "CoT.pdf"])
Expand All @@ -253,6 +268,7 @@ vector_store.upsert_text_artifacts(
```

#### After

```python
artifact = PdfLoader().load("attention.pdf")
chunks = Chunker().chunk(artifact)
Expand Down Expand Up @@ -281,9 +297,10 @@ audio_media = MediaArtifact(
media_type="audio",
format="wav"
)
```
```

#### After

```python
image_artifact = ImageArtifact(
b"image_data",
Expand All @@ -309,6 +326,7 @@ image_artifact = ImageArtifact(
```

#### After

```python
image_artifact = ImageArtifact(
b"image_data",
Expand All @@ -329,6 +347,7 @@ print(type(artifact.value)) # <class 'dict'>
```

#### After

```python
artifact = TextArtifact("name: John\nage: 30")
print(artifact.value) # name: John\nage: 30
Expand All @@ -337,11 +356,11 @@ print(type(artifact.value)) # <class 'str'>

If you require storing a dictionary as an Artifact, you can use `GenericArtifact` instead.

### `CsvLoader`, `DataframeLoader`, and `SqlLoader` return types
### `CsvLoader`, `DataframeLoader`, and `SqlLoader` return types

`CsvLoader`, `DataframeLoader`, and `SqlLoader` now return a `list[TextArtifact]` instead of `list[CsvRowArtifact]`.

If you require a dictionary, set a custom `formatter_fn` and then parse the text to a dictionary.
If you require a dictionary, set a custom `formatter_fn` and then parse the text to a dictionary.

#### Before

Expand All @@ -353,6 +372,7 @@ print(type(results[0].value)) # <class 'dict'>
```

#### After

```python
results = CsvLoader().load(Path("people.csv").read_text())

Expand All @@ -369,7 +389,7 @@ dict_results = [json.loads(result.value) for result in results]
print(dict_results[0]) # {"name": "John", "age": 30}
print(type(dict_results[0])) # <class 'dict'>
```

### Moved `ImageArtifact.prompt` and `ImageArtifact.model` to `ImageArtifact.meta`

`ImageArtifact.prompt` and `ImageArtifact.model` have been moved to `ImageArtifact.meta`.
Expand All @@ -388,6 +408,7 @@ print(image_artifact.prompt, image_artifact.model) # Generate an image of a cat,
```

#### After

```python
image_artifact = ImageArtifact(
b"image_data",
Expand All @@ -398,7 +419,6 @@ image_artifact = ImageArtifact(
print(image_artifact.meta["prompt"], image_artifact.meta["model"]) # Generate an image of a cat, DALL-E
```


## 0.30.X to 0.31.X

### Exceptions Over `ErrorArtifact`s
Expand All @@ -407,6 +427,7 @@ Drivers, Loaders, and Engines now raise exceptions rather than returning `ErrorA
Update any logic that expects `ErrorArtifact` to handle exceptions instead.

#### Before

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

Expand All @@ -415,6 +436,7 @@ if isinstance(artifacts, ErrorArtifact):
```

#### After

```python
try:
artifacts = WebLoader().load("https://www.griptape.ai")
Expand All @@ -427,6 +449,7 @@ except Exception as e:
`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.

#### Before

```python
local_driver_with_file = LocalConversationMemoryDriver(
file_path="my_file.json"
Expand All @@ -439,6 +462,7 @@ assert local_driver.file_path == "griptape_memory.json"
```

#### After

```python
local_driver_with_file = LocalConversationMemoryDriver(
persist_file="my_file.json"
Expand All @@ -455,6 +479,7 @@ assert local_driver.persist_file is None
`BaseConversationMemoryDriver.driver` has been renamed to `conversation_memory_driver`. Method signatures for `.store` and `.load` have been changed.

#### Before

```python
memory_driver = LocalConversationMemoryDriver()

Expand All @@ -468,6 +493,7 @@ memory_driver.store(conversation_memory)
```

#### After

```python
memory_driver = LocalConversationMemoryDriver()

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

Griptape is a modular Python framework for building AI-powered applications that securely connect to your enterprise data and APIs. It offers developers the ability to maintain control and flexibility at every step.


## 🛠️ Core Components

### 🏗️ Structures
Expand Down Expand Up @@ -68,7 +67,7 @@ Engines wrap Drivers and provide use-case-specific functionality:

Please refer to [Griptape Docs](https://docs.griptape.ai/) for:

- Getting started guides.
- Getting started guides.
- Core concepts and design overviews.
- Examples.
- Contribution guidelines.
Expand Down Expand Up @@ -103,6 +102,7 @@ agent.run("https://griptape.ai", "griptape.txt")
```

And here is the output:

```
[08/12/24 14:48:15] INFO ToolkitTask c90d263ec69046e8b30323c131ae4ba0
Input: Load https://griptape.ai, summarize it, and store it in a file called griptape.txt.
Expand Down Expand Up @@ -169,9 +169,9 @@ The important thing to note here is that no matter how big the webpage is it can

In the above example, we set [off_prompt](https://docs.griptape.ai/stable/griptape-framework/structures/task-memory.md#off-prompt) to `True`, which means that the LLM can never see the data it manipulates, but can send it to other Tools.

> [!IMPORTANT]
> \[!IMPORTANT\]\
> This example uses Griptape's [ToolkitTask](https://docs.griptape.ai/stable/griptape-framework/structures/tasks/#toolkit-task), which requires a highly capable LLM to function correctly. By default, Griptape uses the [OpenAiChatPromptDriver](https://docs.griptape.ai/stable/griptape-framework/drivers/prompt-drivers/#openai-chat); for another powerful LLM try swapping to the [AnthropicPromptDriver](https://docs.griptape.ai/stable/griptape-framework/drivers/prompt-drivers/#anthropic)!
If you're using a less powerful LLM, consider using the [ToolTask](https://docs.griptape.ai/stable/griptape-framework/structures/tasks/#tool-task) instead, as the `ToolkitTask` might not work properly or at all.
> If you're using a less powerful LLM, consider using the [ToolTask](https://docs.griptape.ai/stable/griptape-framework/structures/tasks/#tool-task) instead, as the `ToolkitTask` might not work properly or at all.
[Check out our docs](https://docs.griptape.ai/stable/griptape-framework/drivers/prompt-drivers/) to learn more about how to use Griptape with other LLM providers like Anthropic, Claude, Hugging Face, and Azure.

Expand All @@ -193,9 +193,9 @@ We welcome and encourage pull requests. To streamline the process, please follow

1. **Existing Issues:** Please submit pull requests only for existing issues. If you want to work on new functionality or fix a bug that hasn't been addressed yet, please first submit an issue. This allows the Griptape team to internally process the request and provide a public response.

2. **Branch:** Submit all pull requests to the `dev` branch. This helps us manage changes and integrate them smoothly.
1. **Branch:** Submit all pull requests to the `dev` branch. This helps us manage changes and integrate them smoothly.

3. **Unit Tests:** Ensure that your pull request passes all existing unit tests. Additionally, if you are introducing new code, please include new unit tests to validate its functionality.
1. **Unit Tests:** Ensure that your pull request passes all existing unit tests. Additionally, if you are introducing new code, please include new unit tests to validate its functionality.

Run `make test/unit` to execute the test suite locally.

Expand Down
9 changes: 5 additions & 4 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ We welcome and encourage pull requests. To streamline the process, please follow

1. **Existing Issues:** Please submit pull requests only for existing issues. If you want to add new documentation or fix a documentation issue that hasn't been addressed yet, please first submit an issue. This allows the Griptape team to internally process the request and provide a public response.

2. **Branch:** Submit all pull requests to the `dev` branch. This helps us manage changes and integrate them smoothly.
1. **Branch:** Submit all pull requests to the `dev` branch. This helps us manage changes and integrate them smoothly.

## Getting Started

Griptape docs are built using [MkDocs](https://squidfunk.github.io/mkdocs-material/getting-started/). Dependencies are managed using [Poetry](https://python-poetry.org/).

To contribute to Griptape docs, install the `docs` extra with:

```poetry install --with docs```
`poetry install --with docs`

Then serve the documentation locally with:

```poetry run mkdocs serve```
`poetry run mkdocs serve`

You should see something similar to the following:
You should see something similar to the following:

```
INFO - Building documentation...
Expand Down
Loading

0 comments on commit 33c8a99

Please sign in to comment.