Assistant
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.assistant.griptape_cloud 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)
[02/27/25 20:22:40] INFO AssistantTask 4e81788ad97947488ded0b1afa0c4ca3
Input: Write me long poem
Certainly! Here's a long poem for you:
---
**Whispers of the Eternal Sky**
Beneath the vast and endless dome,
Where stars like ancient lanterns roam,
A world unfolds, both wild and free,
A tapestry of mystery.
The mountains rise with jagged grace,
Their peaks adorned in snow’s embrace.
They pierce the heavens, bold and high,
And kiss the edges of the sky.
The rivers carve their winding trails,
Through verdant woods and shadowed vales.
They sing a song, both soft and deep,
A melody the earth will keep.
The forests hum with life unseen,
A symphony of gold and green.
The whispering leaves, the rustling air,
A secret language everywhere.
The ocean roars, a restless king,
Its waves like horses galloping.
It holds the moon within its gaze,
And dances in her silver rays.
The desert sprawls, a golden sea,
Its dunes a hymn to eternity.
The wind, a painter, shifts the sand,
And sculpts the earth with unseen hands.
The meadows bloom with colors bright,
A canvas drenched in morning light.
The flowers sway, a gentle throng,
As nature hums her timeless song.
And yet, amidst this grand display,
The heart of man begins to stray.
We build our towers, scrape the skies,
And blind ourselves with fleeting lies.
We chase the clock, we crave the gold,
We trade the young to feed the old.
We pave the earth, we cage the air,
And seldom pause to see, to care.
But still the earth, with patient grace,
Endures the scars upon her face.
She whispers soft, she calls us near,
To listen close, to truly hear.
The rustle of the autumn leaves,
The sigh of wind through ancient eaves,
The laughter of a bubbling brook,
The wisdom in a mountain’s look.
She speaks of balance, speaks of peace,
Of cycles that will never cease.
Of how the stars, though far apart,
Are bound by threads of cosmic art.
And so, beneath the endless sky,
We find the truth we can’t deny:
That we are but a fleeting spark,
A moment’s glow within the dark.
Yet in that spark, a fire burns,
A yearning soul that twists and turns.
To love, to dream, to seek, to know,
To plant a seed, to watch it grow.
For though the earth is vast and wide,
And time flows like a ceaseless tide,
We are its stewards, strong and small,
Its beating heart, its all in all.
So let us walk with gentle tread,
And honor those who came and fled.
Let’s weave our lives with care and grace,
And leave no scars upon her face.
For when the stars have had their say,
And night gives way to newborn day,
The earth will hum, the sky will sing,
And life will bloom in endless spring.
---
I hope you enjoyed this poem! Let me know if you'd like me to write another or explore a different theme. 🌟
[02/27/25 20:22:57] INFO AssistantTask 4e81788ad97947488ded0b1afa0c4ca3
Output: Certainly! Here's a long poem for you:
---
**Whispers of the Eternal Sky**
Beneath the vast and endless dome,
Where stars like ancient lanterns roam,
A world unfolds, both wild and free,
A tapestry of mystery.
The mountains rise with jagged grace,
Their peaks adorned in snow’s embrace.
They pierce the heavens, bold and high,
And kiss the edges of the sky.
The rivers carve their winding trails,
Through verdant woods and shadowed vales.
They sing a song, both soft and deep,
A melody the earth will keep.
The forests hum with life unseen,
A symphony of gold and green.
The whispering leaves, the rustling air,
A secret language everywhere.
The ocean roars, a restless king,
Its waves like horses galloping.
It holds the moon within its gaze,
And dances in her silver rays.
The desert sprawls, a golden sea,
Its dunes a hymn to eternity.
The wind, a painter, shifts the sand,
And sculpts the earth with unseen hands.
The meadows bloom with colors bright,
A canvas drenched in morning light.
The flowers sway, a gentle throng,
As nature hums her timeless song.
And yet, amidst this grand display,
The heart of man begins to stray.
We build our towers, scrape the skies,
And blind ourselves with fleeting lies.
We chase the clock, we crave the gold,
We trade the young to feed the old.
We pave the earth, we cage the air,
And seldom pause to see, to care.
But still the earth, with patient grace,
Endures the scars upon her face.
She whispers soft, she calls us near,
To listen close, to truly hear.
The rustle of the autumn leaves,
The sigh of wind through ancient eaves,
The laughter of a bubbling brook,
The wisdom in a mountain’s look.
She speaks of balance, speaks of peace,
Of cycles that will never cease.
Of how the stars, though far apart,
Are bound by threads of cosmic art.
And so, beneath the endless sky,
We find the truth we can’t deny:
That we are but a fleeting spark,
A moment’s glow within the dark.
Yet in that spark, a fire burns,
A yearning soul that twists and turns.
To love, to dream, to seek, to know,
To plant a seed, to watch it grow.
For though the earth is vast and wide,
And time flows like a ceaseless tide,
We are its stewards, strong and small,
Its beating heart, its all in all.
So let us walk with gentle tread,
And honor those who came and fled.
Let’s weave our lives with care and grace,
And leave no scars upon her face.
For when the stars have had their say,
And night gives way to newborn day,
The earth will hum, the sky will sing,
And life will bloom in endless spring.
---
I hope you enjoyed this poem! Let me know if you'd
like me to write another or explore a different
theme. 🌟
OpenAI
The OpenAiAssistantDriver is used to run OpenAI Assistants.
import os
from griptape.drivers.assistant.openai 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)
[02/27/25 20:25:28] INFO AssistantTask e43f76a1900240d793baac672f85b3bb
Input: I need to solve the equation `3x + 11 = 14`.
Can you help me?
Certainly! Let's solve the equation \(3x + 11 = 14\) step-by-step:
1. **Subtract 11 from both sides** to isolate the term with \(3x\):
\[
3x + 11 - 11 = 14 - 11
\]
This simplifies to:
\[
3x = 3
\]
2. **Divide both sides by 3** to solve for \(x\):
\[
\frac{3x}{3} = \frac{3}{3}
\]
This results in:
\[
x = 1
\]
Thus, the solution to the equation \(3x + 11 = 14\) is \(x = 1\).[02/27/25 20:26:15] INFO AssistantTask e43f76a1900240d793baac672f85b3bb
Output: Certainly! Let's solve the equation \(3x +
11 = 14\) step-by-step:
1. **Subtract 11 from both sides** to isolate the
term with \(3x\):
\[
3x + 11 - 11 = 14 - 11
\]
This simplifies to:
\[
3x = 3
\]
2. **Divide both sides by 3** to solve for \(x\):
\[
\frac{3x}{3} = \frac{3}{3}
\]
This results in:
\[
x = 1
\]
Thus, the solution to the equation \(3x + 11 = 14\)
is \(x = 1\).