Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #198 from griptape-ai/release/v0.22.0
Browse files Browse the repository at this point in the history
Release/v0.22.0
  • Loading branch information
collindutter authored Jan 11, 2024
2 parents 11edc54 + 5a44b95 commit 39824cc
Show file tree
Hide file tree
Showing 30 changed files with 1,429 additions and 636 deletions.
6 changes: 1 addition & 5 deletions .github/actions/init-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@ runs:

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --with docs --with test
run: poetry install --no-interaction --no-root --with docs --with test --all-extras
shell: bash

- name: Install project
run: poetry install --no-interaction --with docs --with test
shell: bash

- name: Activate venv
run: |
source .venv/bin/activate
Expand Down
17 changes: 11 additions & 6 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,26 @@ jobs:
SAGEMAKER_LLAMA_ENDPOINT_NAME: ${{ secrets.INTEG_LLAMA_ENDPOINT_NAME }}
SAGEMAKER_FALCON_ENDPOINT_NAME: ${{ secrets.INTEG_FALCON_ENDPOINT_NAME }}
HUGGINGFACE_HUB_ACCESS_TOKEN: ${{ secrets.INTEG_HUGGINGFACE_HUB_ACCESS_TOKEN }}
AZURE_OPENAI_API_BASE_1: ${{ secrets.INTEG_AZURE_OPENAI_API_BASE_1 }}
AZURE_OPENAI_API_KEY_1: ${{ secrets.INTEG_AZURE_OPENAI_API_KEY_1 }}
AZURE_OPENAI_API_BASE_2: ${{ secrets.INTEG_AZURE_OPENAI_API_BASE_2 }}
AZURE_OPENAI_API_KEY_2: ${{ secrets.INTEG_AZURE_OPENAI_API_KEY_2 }}
AZURE_OPENAI_35_16k_DEPLOYMENT_ID: ${{ secrets.INTEG_OPENAI_35_16k_DEPLOYMENT_ID }}
AZURE_OPENAI_ENDPOINT: ${{ secrets.INTEG_AZURE_OPENAI_ENDPOINT }}
AZURE_OPENAI_API_KEY: ${{ secrets.INTEG_AZURE_OPENAI_API_KEY}}
AZURE_OPENAI_35_TURBO_16k_DEPLOYMENT_ID: ${{ secrets.INTEG_OPENAI_35_TURBO_16k_DEPLOYMENT_ID }}
AZURE_OPENAI_DAVINCI_DEPLOYMENT_ID: ${{ secrets.INTEG_OPENAI_DAVINCI_DEPLOYMENT_ID }}
AZURE_OPENAI_4_DEPLOYMENT_ID: ${{ secrets.INTEG_OPENAI_4_DEPLOYMENT_ID }}
AZURE_OPENAI_4_32k_DEPLOYMENT_ID: ${{ secrets.INTEG_OPENAI_4_32k_DEPLOYMENT_ID }}
AZURE_OPENAI_DALL_E_3_DEPLOYMENT_ID: ${{ secrets.INTEG_AZURE_OPENAI_DALL_E_3_DEPLOYMENT_ID }}
AZURE_OPENAI_DEV_2_API_BASE: ${{ secrets.INTEG_AZURE_OPENAI_DEV_2_API_BASE }}
AZURE_OPENAI_DEV_2_API_KEY: ${{ secrets.INTEG_AZURE_OPENAI_DEV_2_API_KEY }}
COHERE_API_KEY: ${{ secrets.INTEG_COHERE_API_KEY }}
GOOGLE_OWNER_EMAIL: ${{ secrets.INTEG_GOOGLE_OWNER_EMAIL }}
LEONARDO_API_KEY: ${{ secrets.INTEG_LEONARDO_API_KEY }}
LEONARDO_MODEL_ID: ${{ secrets.INTEG_LEONARDO_MODEL_ID }}
SAGEMAKER_TENSORFLOW_HUB_MODEL: ${{ secrets.INTEG_SAGEMAKER_TENSORFLOW_HUB_MODEL }}
SAGEMAKER_HUGGINGFACE_MODEL: ${{ secrets.INTEG_SAGEMAKER_HUGGINGFACE_MODEL }}

steps:
- name: Checkout actions
uses: actions/checkout@v3
- name: Init environment
uses: ./.github/actions/init-environment
- name: Run integration tests
run: pytest -xvs tests/integration
run: pytest -v tests/integration
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
publish:
.PHONY: version
version: ## Bump version and push to release branch.
@poetry version $(v)
@git add pyproject.toml
@git commit -m "Version bump v$$(poetry version -s)"
@git push origin release/v$$(poetry version -s)

.PHONY: publish
publish: ## Push git tag
@git tag v$$(poetry version -s)
@git push
@git push --tags

.DEFAULT_GOAL := help
.PHONY: help
help: ## Print Makefile help text.
@# Matches targets with a comment in the format <target>: ## <comment>
@# then formats help output using these values.
@grep -E '^[a-zA-Z_\/-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; \
{printf "\033[36m%-12s\033[0m%s\n", $$1, $$2}'
2 changes: 1 addition & 1 deletion docs/griptape-cloud/getting-started/quickstart-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Step 7. Deploy your application to the cloud
You can use the Griptape CLI to deploy your application to the cloud.

```
user@machine-name demo_app % gt cloud create-deployment --api-id 12345678-8f3e-4028-9934-42e0cd69860a --directory ~/workplace/demo_app
user@machine-name demo_app % gt cloud create-deployment --app-id 12345678-8f3e-4028-9934-42e0cd69860a --directory ~/workplace/demo_app
{'app_id': '12345678-8f3e-4028-9934-42e0cd69860a', 'created_at': '2023-12-19T00:16:36.663Z', 'created_by': '12345678-9b16-408a-b5d7-e83044d820f4', 'deployment_id': '12345678-12cd-4003-9ee1-b6b01f7927ea', 'status': 'QUEUED'}
```

Expand Down
4 changes: 4 additions & 0 deletions docs/griptape-framework/data/artifacts.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ Each blob has a [name](../../reference/griptape/artifacts/base_artifact.md#gript
[dir](../../reference/griptape/artifacts/blob_artifact.md#griptape.artifacts.blob_artifact.BlobArtifact.dir) to uniquely identify stored objects.

[TaskMemory](../../reference/griptape/memory/task/task_memory.md) automatically stores [BlobArtifact](../../reference/griptape/artifacts/blob_artifact.md)s returned by tool activities that can be reused by other tools.

## ImageArtifact

An [ImageArtifact](../../reference/griptape/artifacts/image_artifact.md) is used for passing images back to the LLM. In addition to binary image data, an ImageArtifact includes image metadata like MIME type, dimensions, and prompt and model information for images returned by [image generation Drivers](../structures/image-generation-drivers.md). It inherits from [BlobArtifact](#blobartifact).
60 changes: 51 additions & 9 deletions docs/griptape-framework/data/embedding-drivers.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ Embeddings in Griptape are multidimensional representations of text data. Embedd

Griptape provides a way to build Embedding Drivers that are reused in downstream framework components. Every Embedding Driver has two basic methods that can be used to generate embeddings:

* [embed_text_artifact()](../../reference/griptape/drivers/embedding/base_embedding_driver.md#griptape.drivers.embedding.base_embedding_driver.BaseEmbeddingDriver.embed_text_artifact) for [TextArtifact](../../reference/griptape/artifacts/text_artifact.md)s
* [embed_string()](../../reference/griptape/drivers/embedding/base_embedding_driver.md#griptape.drivers.embedding.base_embedding_driver.BaseEmbeddingDriver.embed_string) for any string
* [embed_text_artifact()](../../reference/griptape/drivers/embedding/base_embedding_driver.md#griptape.drivers.embedding.base_embedding_driver.BaseEmbeddingDriver.embed_text_artifact) for [TextArtifact](../../reference/griptape/artifacts/text_artifact.md)s.
* [embed_string()](../../reference/griptape/drivers/embedding/base_embedding_driver.md#griptape.drivers.embedding.base_embedding_driver.BaseEmbeddingDriver.embed_string) for any string.

!!! info
More embedding drivers are coming soon.
You can optionally provide a [Tokenizer](../structures/tokenizers.md) via the [tokenizer](../../reference/griptape/drivers/embedding/base_embedding_driver.md#griptape.drivers.embedding.base_embedding_driver.BaseEmbeddingDriver.tokenizer) field to have the Driver automatically chunk the input text to fit into the token limit.

## Embedding Drivers

### OpenAI Embeddings

The [OpenAiEmbeddingDriver](../../reference/griptape/drivers/embedding/openai_embedding_driver.md) uses [OpenAI Embeddings API](https://platform.openai.com/docs/guides/embeddings) to generate embeddings for texts of arbitrary length. This driver automatically chunks the input text to fit into the token limit.
The [OpenAiEmbeddingDriver](../../reference/griptape/drivers/embedding/openai_embedding_driver.md) uses the [OpenAI Embeddings API](https://platform.openai.com/docs/guides/embeddings).


```python
from griptape.drivers import OpenAiEmbeddingDriver
Expand All @@ -37,12 +37,12 @@ with updated defaults.
!!! info
This driver requires the `drivers-embedding-amazon-bedrock` [extra](../index.md#extras).

The [BedrockTitanEmbeddingDriver](../../reference/griptape/drivers/embedding/bedrock_titan_embedding_driver.md) uses the [Amazon Bedrock Embeddings API](https://docs.aws.amazon.com/bedrock/latest/userguide/embeddings.html).
The [AmazonBedrockTitanEmbeddingDriver](../../reference/griptape/drivers/embedding/amazon_bedrock_titan_embedding_driver.md) uses the [Amazon Bedrock Embeddings API](https://docs.aws.amazon.com/bedrock/latest/userguide/embeddings.html).

```python
from griptape.drivers import BedrockTitanEmbeddingDriver
from griptape.drivers import AmazonBedrockTitanEmbeddingDriver

embeddings = BedrockTitanEmbeddingDriver().embed_string("Hello world!")
embeddings = AmazonBedrockTitanEmbeddingDriver().embed_string("Hello world!")

# display the first 3 embeddings
print(embeddings[:3])
Expand Down Expand Up @@ -78,6 +78,49 @@ driver = HuggingFaceHubEmbeddingDriver(

embeddings = driver.embed_string("Hello world!")

# display the first 3 embeddings
print(embeddings[:3])
```
### Multi Model Embedding Drivers
Certain embeddings providers such as Amazon SageMaker support many types of models, each with their own slight differences in parameters and response formats. To support this variation across models, these Embedding Drivers takes a [Embedding Model Driver](../../reference/griptape/drivers/embedding_model/base_embedding_model_driver.md)
through the [embedding_model_driver](../../reference/griptape/drivers/embedding/base_multi_model_embedding_driver.md#griptape.drivers.embedding.base_multi_model_embedding_driver.BaseMultiModelEmbeddingDriver.embedding_model_driver) parameter.
[Embedding Model Driver](../../reference/griptape/drivers/embedding_model/base_embedding_model_driver.md)s allows for model-specific customization for Embedding Drivers.

#### SageMaker Embeddings

The [AmazonSageMakerEmbeddingDriver](../../reference/griptape/drivers/embedding/amazon_sagemaker_embedding_driver.md) uses the [Amazon SageMaker Endpoints](https://docs.aws.amazon.com/sagemaker/latest/dg/realtime-endpoints.html) to generate embeddings on AWS.

!!! info
This driver requires the `drivers-embedding-amazon-sagemaker` [extra](../index.md#extras).

##### TensorFlow Hub Models
```python ignore
import os
from griptape.drivers import AmazonSageMakerEmbeddingDriver, SageMakerTensorFlowHubEmbeddingModelDriver

driver = AmazonSageMakerEmbeddingDriver(
model=os.environ["SAGEMAKER_TENSORFLOW_HUB_MODEL"],
embedding_model_driver=SageMakerTensorFlowHubEmbeddingModelDriver(),
)

embeddings = driver.embed_string("Hello world!")

# display the first 3 embeddings
print(embeddings[:3])
```

##### HuggingFace Models
```python ignore
import os
from griptape.drivers import AmazonSageMakerEmbeddingDriver, SageMakerHuggingFaceEmbeddingModelDriver

driver = AmazonSageMakerEmbeddingDriver(
model=os.environ["SAGEMAKER_HUGGINGFACE_MODEL"],
embedding_model_driver=SageMakerHuggingFaceEmbeddingModelDriver(),
)

embeddings = driver.embed_string("Hello world!")

# display the first 3 embeddings
print(embeddings[:3])
```
Expand All @@ -96,4 +139,3 @@ agent = Agent(
)

agent.run("based on https://www.griptape.ai/, tell me what Griptape is")
```
53 changes: 15 additions & 38 deletions docs/griptape-framework/data/extraction-engines.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,28 @@ The CSV Extraction Engine is designed specifically for extracting data from CSV-

```python
from griptape.engines import CsvExtractionEngine
from griptape.artifacts import ListArtifact, ErrorArtifact

# Initialize the CsvExtractionEngine instance
csv_engine = CsvExtractionEngine()

# Given a sample text which contains CSV content
# Define some unstructured data
sample_text = """
name, age, location
Alice, 28, New York
Bob, 35, California
Charlie, 40, Texas
Alice, 28, lives in New York.
Bob, 35 lives in California.
Charlie is 40 and lives in Texas.
"""

# Extract CSV rows using the engine
result = csv_engine.extract(sample_text, column_names=["name", "age", "location"])

# Check and display the result
if isinstance(result, ListArtifact):
for row in result.value:
print(row.value) # This will print each row in the CSV content
elif isinstance(result, ErrorArtifact):
print(f"Error: {result.value}") # Print error if there's any issue in extraction
for row in result.value:
print(row.to_text())
```
```
{'name': 'name, age, location'}
{'name': 'Alice, 28, New York'}
{'name': 'Bob, 35, California'}
{'name': 'Charlie, 40, Texas'}
name,age,location
Alice,28,New York
Bob,35,California
Charlie,40,Texas
```

## JSON Extraction Engine
Expand All @@ -51,27 +45,14 @@ The JSON Extraction Engine is tailored for extracting data from JSON-formatted c

```python
from griptape.engines import JsonExtractionEngine
from griptape.artifacts import ListArtifact, ErrorArtifact
from schema import Schema

json_engine = JsonExtractionEngine()

# Given a sample JSON text
# Define some unstructured data
sample_json_text = """
{
"users": [
{
"name": "Alice",
"age": 28,
"location": "New York"
},
{
"name": "Bob",
"age": 35,
"location": "California"
}
]
}
Alice (Age 28) lives in New York.
Bob (Age 35) lives in California.
"""

# Define a schema for extraction
Expand All @@ -82,12 +63,8 @@ user_schema = Schema(
# Extract data using the engine
result = json_engine.extract(sample_json_text, template_schema=user_schema)

# Check and display the result
if isinstance(result, ListArtifact):
for artifact in result.value:
print(artifact.value) # This will print each extracted artifact
elif isinstance(result, ErrorArtifact):
print(f"Error: {result.value}") # Print error if there's any issue in extraction
for artifact in result.value:
print(artifact.value)
```
```
{'name': 'Alice', 'age': 28, 'location': 'New York'}
Expand Down
Loading

0 comments on commit 39824cc

Please sign in to comment.