Skip to content

Instantly share code, notes, and snippets.

@kyleroche
Created April 20, 2023 21:56
Show Gist options
  • Save kyleroche/fa3715caf27d404fc9638828a002d575 to your computer and use it in GitHub Desktop.
Save kyleroche/fa3715caf27d404fc9638828a002d575 to your computer and use it in GitHub Desktop.
Getting Started with Griptape
from decouple import config
from griptape.tools import WebScraper, Calculator
from griptape.flow import utils
from griptape.flow.memory import PipelineMemory
from griptape.flow.steps import PromptStep, ToolkitStep
from griptape.flow.structures import Pipeline
from griptape.flow.utils import ToolLoader
scraper = WebScraper(
openai_api_key=config("OPENAI_API_KEY")
)
calculator = Calculator()
pipeline = Pipeline(
memory=PipelineMemory(),
tool_loader=ToolLoader(
tools=[calculator, scraper]
)
)
pipeline.add_steps(
ToolkitStep(
tool_names=[calculator.name, scraper.name]
),
PromptStep(
"Say the following like a pirate: {{ input }}"
)
)
pipeline.run("Give me a summary of https://en.wikipedia.org/wiki/Large_language_model")
print(utils.Conversation(pipeline.memory).to_string())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment