Assistant Drivers
Overview
Assistant Drivers can be used to interact with various "assistant" services.
Assistant Drivers
Griptape Cloud
The GriptapeCloudAssistantDriver is used to run Griptape Cloud Assistants.
import os
from griptape.drivers import GriptapeCloudAssistantDriver
from griptape.structures import Pipeline
from griptape.tasks import AssistantTask
from griptape.utils.stream import Stream
pipeline = Pipeline(
tasks=[
AssistantTask(
assistant_driver=GriptapeCloudAssistantDriver(
assistant_id=os.environ["GT_CLOUD_ASSISTANT_ID"],
stream=True,
),
),
]
)
for chunk in Stream(pipeline).run("Write me long poem"):
print(chunk, end="", flush=True)
OpenAI
The OpenAiAssistantDriver is used to run OpenAI Assistants.
import os
from griptape.drivers import OpenAiAssistantDriver
from griptape.structures import Pipeline
from griptape.tasks import AssistantTask
from griptape.utils.stream import Stream
pipeline = Pipeline(
tasks=[
AssistantTask(
assistant_driver=OpenAiAssistantDriver(
assistant_id=os.environ["OPENAI_ASSISTANT_ID"], thread_id=os.environ["OPENAI_THREAD_ID"]
),
),
]
)
for chunk in Stream(pipeline).run("I need to solve the equation `3x + 11 = 14`. Can you help me?"):
print(chunk, end="", flush=True)