Skip to content

Commit

Permalink
Merge branch 'dev' into feature/native-functions
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter committed Jul 10, 2024
2 parents 9c44a62 + d987f1a commit 3d4fd4a
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 120 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

## [0.28.1] - 2024-07-10

### Fixed
- Sending empty system content in `PromptTask`.
- Throttling issues with `DuckDuckGoWebSearchDriver`.

## [0.28.0] - 2024-07-09
### Added
- `RagEngine` is an abstraction for implementing modular RAG pipelines.
Expand Down
2 changes: 1 addition & 1 deletion docs/griptape-framework/structures/agents.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Overview

An [Agent](../../reference/griptape/structures/agent.md) is the quickest way to get started with Griptape.
Agents take in [tools](../../reference/griptape/structures/agent.md#griptape.structures.agent.Agent.tools) and [input_template](../../reference/griptape/structures/agent.md#griptape.structures.agent.Agent.input_template)
Agents take in [tools](../../reference/griptape/structures/agent.md#griptape.structures.agent.Agent.tools) and [input](../../reference/griptape/structures/agent.md#griptape.structures.agent.Agent.input)
directly, which the agent uses to dynamically determine whether to use a [Prompt Task](./tasks.md#prompt-task) or [Toolkit Task](./tasks.md#toolkit-task).

If [tools](../../reference/griptape/structures/agent.md#griptape.structures.agent.Agent.tools) are passed provided to the Agent, a [Toolkit Task](./tasks.md#toolkit-task) will be used. If no [tools](../../reference/griptape/structures/agent.md#griptape.structures.agent.Agent.tools)
Expand Down
2 changes: 1 addition & 1 deletion docs/griptape-framework/structures/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ agent = Agent()
with open("tests/resources/mountain.jpg", "rb") as f:
image_artifact = ImageLoader().load(f.read())

agent.run(["What's in this image?", image_artifact])
agent.run([image_artifact, "What's in this image?"])
```

```
Expand Down
4 changes: 3 additions & 1 deletion griptape/tasks/prompt_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def prompt_stack(self) -> PromptStack:
stack = PromptStack()
memory = self.structure.conversation_memory

stack.add_system_message(self.generate_system_template(self))
system_template = self.generate_system_template(self)
if system_template:
stack.add_system_message(system_template)

stack.add_user_message(self.input)

Expand Down
166 changes: 55 additions & 111 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "griptape"
version = "0.28.0"
version = "0.28.1"
description = "Modular Python framework for LLM workflows, tools, memory, and data."
authors = ["Griptape <[email protected]>"]
license = "Apache 2.0"
Expand Down Expand Up @@ -55,7 +55,7 @@ torch = {version = "^2.3.0", optional = true}
qdrant-client = { version = ">=1.9.1", optional = true }
pusher = {version = "^3.3.2", optional = true}
ollama = {version = "^0.2.1", optional = true}
duckduckgo-search = {version = "^6.1.6", optional = true}
duckduckgo-search = {version = "^6.1.12", optional = true}

# loaders
pandas = {version = "^1.3", optional = true}
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/structures/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def test_add_tasks(self):
assert True

def test_prompt_stack_without_memory(self):
agent = Agent(prompt_driver=MockPromptDriver(), conversation_memory=None)
agent = Agent(prompt_driver=MockPromptDriver(), conversation_memory=None, rules=[Rule("test")])

task1 = PromptTask("test")

Expand All @@ -177,7 +177,7 @@ def test_prompt_stack_without_memory(self):
assert len(task1.prompt_stack.messages) == 3

def test_prompt_stack_with_memory(self):
agent = Agent(prompt_driver=MockPromptDriver(), conversation_memory=ConversationMemory())
agent = Agent(prompt_driver=MockPromptDriver(), conversation_memory=ConversationMemory(), rules=[Rule("test")])

task1 = PromptTask("test")

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/structures/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def test_insert_task_at_end(self):
assert [child.id for child in third_task.children] == []

def test_prompt_stack_without_memory(self):
pipeline = Pipeline(conversation_memory=None, prompt_driver=MockPromptDriver())
pipeline = Pipeline(conversation_memory=None, prompt_driver=MockPromptDriver(), rules=[Rule("test")])

task1 = PromptTask("test")
task2 = PromptTask("test")
Expand All @@ -291,7 +291,7 @@ def test_prompt_stack_without_memory(self):
assert len(task2.prompt_stack.messages) == 3

def test_prompt_stack_with_memory(self):
pipeline = Pipeline(prompt_driver=MockPromptDriver())
pipeline = Pipeline(prompt_driver=MockPromptDriver(), rules=[Rule("test")])

task1 = PromptTask("test")
task2 = PromptTask("test")
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/tasks/test_prompt_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from griptape.artifacts.text_artifact import TextArtifact
from tests.mocks.mock_structure_config import MockStructureConfig
from griptape.tasks import PromptTask
from griptape.rules import Rule
from tests.mocks.mock_prompt_driver import MockPromptDriver
from griptape.structures import Pipeline

Expand Down Expand Up @@ -122,3 +123,20 @@ def test_input(self):
task = PromptTask({"default": "test"})

assert task.input.value == str({"default": "test"})

def test_prompt_stack(self):
task = PromptTask("{{ test }}", context={"test": "test value"}, rules=[Rule("test rule")])

Pipeline().add_task(task)

assert len(task.prompt_stack.messages) == 2
assert task.prompt_stack.messages[0].is_system()
assert task.prompt_stack.messages[1].is_user()

def test_prompt_stack_empty_system_content(self):
task = PromptTask("{{ test }}", context={"test": "test value"})

Pipeline().add_task(task)

assert len(task.prompt_stack.messages) == 1
assert task.prompt_stack.messages[0].is_user()

0 comments on commit 3d4fd4a

Please sign in to comment.