Skip to content

Commit

Permalink
Simplify example
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter committed Jul 16, 2024
1 parent 2222ee3 commit 29e046a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
18 changes: 6 additions & 12 deletions docs/examples/talk-to-a-video.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ Note that because we are using Gemini-specific features, this will not work with
import time
from griptape.structures import Agent
from griptape.tasks import PromptTask
from griptape.artifacts import ListArtifact, GenericArtifact, TextArtifact
from griptape.artifacts import GenericArtifact, TextArtifact
from griptape.config import GoogleStructureConfig
import google.generativeai as genai

video_file = genai.upload_file(path="tests/resources/griptape-comfyui.mp4")
video_file = genai.upload_file(path="assets/griptape-comfyui.mp4")
while video_file.state.name == "PROCESSING":
time.sleep(2)
video_file = genai.get_file(video_file.name)
Expand All @@ -20,16 +20,10 @@ if video_file.state.name == "FAILED":

agent = Agent(
config=GoogleStructureConfig(),
tasks=[
PromptTask(
lambda task: ListArtifact(
[
GenericArtifact(video_file),
TextArtifact(task.full_context["args"][0]),
]
)
)
],
input=[
GenericArtifact(video_file),
TextArtifact("Answer this question regarding the video: {{ args[0] }}"),
]
)

agent.run("Are there any scenes that show a character with earings?")
Expand Down
2 changes: 2 additions & 0 deletions griptape/tasks/prompt_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def _process_task_input(
return task_input
elif isinstance(task_input, Callable):
return self._process_task_input(task_input(self))
elif isinstance(task_input, ListArtifact):
return ListArtifact([self._process_task_input(elem) for elem in task_input.value])
elif isinstance(task_input, BaseArtifact):
return task_input
elif isinstance(task_input, (list, tuple)):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/artifacts/test_generic_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class TestImageArtifact:
@pytest.fixture
@pytest.fixture()
def generic_artifact(self):
return GenericArtifact(
value="some generic data",
Expand Down

0 comments on commit 29e046a

Please sign in to comment.