Created
May 13, 2023 20:10
-
-
Save kyleroche/3d57c44c502a986ba2666913f6ea3933 to your computer and use it in GitHub Desktop.
Sample moving SQL results to file manager (on a ramp)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from griptape.memory import Memory | |
| from griptape.executors import DockerExecutor | |
| from griptape.ramps import TextStorageRamp, BlobStorageRamp | |
| from griptape.structures import Pipeline | |
| from griptape.tasks import ToolkitTask, PromptTask | |
| from griptape.tools import WebScraper, TextProcessor, FileManager, SqlClient | |
| # Ramps enable LLMs to store and manipulate data without ever looking at it directly. | |
| text_storage = TextStorageRamp() | |
| blob_storage = BlobStorageRamp() | |
| sql_client = SqlClient( | |
| engine_url="sqlite:////path/acs-1-year-2015.sqlite", | |
| engine_name="sqlite", | |
| ramps={ | |
| "query": [text_storage] | |
| } | |
| ) | |
| # Connect a web scraper to load web pages. | |
| web_scraper = WebScraper( | |
| ramps={ | |
| "get_content": [text_storage] | |
| } | |
| ) | |
| # TextProcessor enables LLMs to summarize and query text. | |
| text_processor = TextProcessor( | |
| ramps={ | |
| "summarize": [text_storage], | |
| "query": [text_storage] | |
| } | |
| ) | |
| # File manager can load and store files locally. | |
| file_manager = FileManager( | |
| ramps={ | |
| "load": [blob_storage], | |
| "save": [text_storage, blob_storage] | |
| } | |
| ) | |
| # Pipelines represent sequences of tasks. | |
| pipeline = Pipeline( | |
| memory=Memory() | |
| ) | |
| pipeline.add_tasks( | |
| # Load up the first argument from `pipeline.run`. | |
| ToolkitTask( | |
| "{{ args[0] }}", | |
| tools=[file_manager, sql_client] | |
| #executor=DockerExecutor() | |
| ) | |
| ) | |
| result = pipeline.run("using the sql table states, get the per capita income by state and store it in states.txt") | |
| #result = pipeline.run("copy README.md to README_new.md") | |
| print(result.output.to_text()) |
Author
kyleroche
commented
May 13, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment