Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/mdformat #1248

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,6 +1,7 @@
# 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 `DataframeLoader`
Expand Down Expand Up @@ -84,11 +85,13 @@ vector_store.upsert_text_artifacts(
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 @@ -112,9 +115,10 @@ audio_media = MediaArtifact(
media_type="audio",
format="wav"
)
```
```

#### After

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

#### After

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

#### After

```python
artifact = TextArtifact("name: John\nage: 30")
print(artifact.value) # name: John\nage: 30
Expand All @@ -168,11 +174,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 @@ -184,6 +190,7 @@ print(type(results[0].value)) # <class 'dict'>
```

#### After

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

Expand All @@ -199,7 +206,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 @@ -218,6 +225,7 @@ print(image_artifact.prompt, image_artifact.model) # Generate an image of a cat,
```

#### After

```python
image_artifact = ImageArtifact(
b"image_data",
Expand All @@ -231,13 +239,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 @@ -249,13 +259,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 @@ -275,6 +287,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 @@ -285,12 +298,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 @@ -307,7 +322,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 @@ -329,6 +344,7 @@ vector_store.upsert_text_artifacts(
```

#### After

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

#### After

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

#### After

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

#### After

```python
artifact = TextArtifact("name: John\nage: 30")
print(artifact.value) # name: John\nage: 30
Expand All @@ -413,11 +432,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 @@ -429,6 +448,7 @@ print(type(results[0].value)) # <class 'dict'>
```

#### After

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

Expand All @@ -445,7 +465,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 @@ -464,6 +484,7 @@ print(image_artifact.prompt, image_artifact.model) # Generate an image of a cat,
```

#### After

```python
image_artifact = ImageArtifact(
b"image_data",
Expand All @@ -474,7 +495,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 @@ -483,6 +503,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 @@ -491,6 +512,7 @@ if isinstance(artifacts, ErrorArtifact):
```

#### After

```python
try:
artifacts = WebLoader().load("https://www.griptape.ai")
Expand All @@ -503,6 +525,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 @@ -515,6 +538,7 @@ assert local_driver.file_path == "griptape_memory.json"
```

#### After

```python
local_driver_with_file = LocalConversationMemoryDriver(
persist_file="my_file.json"
Expand All @@ -531,6 +555,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 @@ -544,6 +569,7 @@ memory_driver.store(conversation_memory)
```

#### After

```python
memory_driver = LocalConversationMemoryDriver()

Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ lint: ## Lint project.
.PHONY: format
format: ## Format project.
@poetry run ruff format
@poetry run mdformat .

.PHONY: check
check: check/format check/lint check/types check/spell ## Run all checks.
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
Loading
Loading