Skip to content

Commit

Permalink
Merge branch 'dev' into feature/tavily-websearch-driver
Browse files Browse the repository at this point in the history
  • Loading branch information
william-price01 authored Sep 17, 2024
2 parents a3a3983 + 04057a1 commit 2604701
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 100 deletions.
8 changes: 7 additions & 1 deletion docs/griptape-cloud/data-sources/create-data-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ You can connect to your personal or company Confluence by providing a URL, [Atla

You can specify a [Structure](../structures/create-structure.md) to run as a Data Source as long as your Structure returns a [`TextArtifact` or `ListArtifact` from the Griptape Framework](../../griptape-framework/data/artifacts.md). You can use this as a way to build custom Data Sources.

## Other Data Source Types
### Other Data Source Types

If you do not see a Data Source configuration you'd wish to use, you can submit a request via [Discord](https://discord.gg/gnWRz88eym) or `[email protected]`.

## Adding Structure as Transform to Data Source (Experimental)

When creating any Data Source, you can optionally specify a [Structure](../structures/create-structure.md) to run as a transform step of your data ingetstion before loading into the vector store. Ensure the Structure you select to run as a transform is configured to take in a `ListArtifact` as its first positional argument and returns either a `TextArtifact` or `ListArtifact`.

Take a look at the [Find and Replace Sample Structure](https://github.com/griptape-ai/griptape-sample-structures/tree/main/griptape-find-replace-transform) for more details on how to implement this for your own Structure.
2 changes: 1 addition & 1 deletion docs/griptape-framework/structures/rulesets.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ A [Ruleset](../../reference/griptape/rules/ruleset.md) can be used to define [Ru
This is particularly useful when you need the LLM to return well-formed data, such as JSON objects, with specific fields and data types.

!!! warning
`JsonSchemaRule` may break [ToolkitTask](../structures/tasks.md#toolkittask) which relies on a specific [output token](https://github.com/griptape-ai/griptape/blob/e6a04c7b88cf9fa5d6bcf4c833ffebfab89a3258/griptape/tasks/toolkit_task.py#L28).
`JsonSchemaRule` may break [ToolkitTask](../structures/tasks.md#toolkit) which relies on a specific [output token](https://github.com/griptape-ai/griptape/blob/e6a04c7b88cf9fa5d6bcf4c833ffebfab89a3258/griptape/tasks/toolkit_task.py#L28).


```python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def _get_structure_run_result(self, structure_run_id: str) -> BaseArtifact | Inf
status = result["status"]

wait_attempts = 0
while status in ("QUEUED", "RUNNING") and wait_attempts < self.structure_run_max_wait_time_attempts:
while (
status not in ("SUCCEEDED", "FAILED", "ERROR", "CANCELLED")
and wait_attempts < self.structure_run_max_wait_time_attempts
):
# wait
time.sleep(self.structure_run_wait_time_interval)
wait_attempts += 1
Expand Down
3 changes: 2 additions & 1 deletion griptape/templates/rules/json_schema.j2
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
You must respond with a JSON object that successfully validates against the following schema: {{json_schema}}
Output valid JSON that matches this schema: {{ json_schema }}
No markdown, code snippets, code blocks, or backticks.
184 changes: 95 additions & 89 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/integration/test_code_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"docs/griptape-framework/drivers/src/observability_drivers_2.py",
"docs/griptape-framework/structures/src/observability_1.py",
"docs/griptape-framework/structures/src/observability_2.py",
"docs/griptape-framework/data/src/loaders_9.py",
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ def driver(self, mocker, mock_requests_post):
from griptape.drivers import GriptapeCloudStructureRunDriver

mock_response = mocker.Mock()
mock_response.json.return_value = {
"description": "fizz buzz",
"output": TextArtifact("foo bar").to_dict(),
"status": "SUCCEEDED",
}
mock_response.json.side_effect = [
{"description": "fizz buzz", "status": "RUNNING"},
{"description": "fizz buzz", "output": TextArtifact("foo bar").to_dict(), "status": "SUCCEEDED"},
]
mocker.patch("requests.get", return_value=mock_response)

return GriptapeCloudStructureRunDriver(
base_url="https://cloud-foo.griptape.ai", api_key="foo bar", structure_id="1", env={"key": "value"}
base_url="https://cloud-foo.griptape.ai",
api_key="foo bar",
structure_id="1",
env={"key": "value"},
structure_run_wait_time_interval=0,
)

def test_run(self, driver, mock_requests_post):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/rules/test_json_schema_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_to_text(self):
rule = JsonSchemaRule(json_schema)
assert (
rule.to_text()
== f"You must respond with a JSON object that successfully validates against the following schema: {json.dumps(json_schema)}"
== f"Output valid JSON that matches this schema: {json.dumps(json_schema)}\nNo markdown, code snippets, code blocks, or backticks."
)

def test___str__(self):
Expand Down

0 comments on commit 2604701

Please sign in to comment.