|
| 1 | +# Postgres |
| 2 | + |
| 3 | +import ToolInfo from "@/components/ToolInfo"; |
| 4 | +import Badges from "@/components/Badges"; |
| 5 | +import TabbedCodeBlock from "@/components/TabbedCodeBlock"; |
| 6 | +import TableOfContents from "@/components/TableOfContents"; |
| 7 | +import ToolFooter from "@/components/ToolFooter"; |
| 8 | + |
| 9 | +<ToolInfo |
| 10 | + description="Enable agents to interact with PostgreSQL databases (read only)." |
| 11 | + author="Arcade" |
| 12 | + codeLink="https://github.com/ArcadeAI/arcade-ai/tree/main/toolkits/postgres" |
| 13 | + authType="database connection string" |
| 14 | + versions={["0.1.0"]} |
| 15 | +/> |
| 16 | + |
| 17 | +<Badges repo="arcadeai/arcade-postgres" /> |
| 18 | + |
| 19 | +The Arcade Postgres toolkit provides a pre-built set of tools for interacting with PostgreSQL databases in a read-only manner. |
| 20 | + |
| 21 | +<Note> |
| 22 | +This toolkit is meant to be an example of how to build a toolkit for a database, and is not intended to be used in production. For production use, we recommend forking this repository and building your own toolkit with use-case specific tools. |
| 23 | +</Note> |
| 24 | + |
| 25 | + |
| 26 | +This repository demonstrates a few concepts to aid in LLM-powered database interactions. |
| 27 | +* Re-use an existing database pool for all tool calls |
| 28 | +* Enforce read-only access to the database |
| 29 | +* Hint to the LLM that both table and schema discovery is required before executing a query |
| 30 | +* Enforce a limit on the number of rows returned by a query |
| 31 | + |
| 32 | +## Available Tools |
| 33 | + |
| 34 | +<TableOfContents |
| 35 | + headers={["Tool Name", "Description"]} |
| 36 | + data={ |
| 37 | + [ |
| 38 | + ['Postgres.DiscoverTables', "Discover all tables in a PostgreSQL database."], |
| 39 | + ['Postgres.GetTableSchema', "Get the schema of a table in a PostgreSQL database."], |
| 40 | + ['Postgres.ExecuteQuery', "Execute a query on a PostgreSQL database."], |
| 41 | + ] |
| 42 | + } |
| 43 | +/> |
| 44 | + |
| 45 | +Note that all tools require the `DATABASE_CONNECTION_STRING` secret to be set. |
| 46 | + |
| 47 | +## Postgres.DiscoverTables |
| 48 | + |
| 49 | +Discover all tables in a PostgreSQL database. |
| 50 | + |
| 51 | +<TabbedCodeBlock |
| 52 | + tabs={[ |
| 53 | + { |
| 54 | + label: "Call the Tool", |
| 55 | + content: { |
| 56 | + Python: [ |
| 57 | + "/examples/integrations/toolkits/postgres/discover_tables_example_call_tool.py", |
| 58 | + ], |
| 59 | + JavaScript: ["/examples/integrations/toolkits/postgres/discover_tables_example_call_tool.js"], |
| 60 | + }, |
| 61 | + } |
| 62 | + ]} |
| 63 | +/> |
| 64 | +## Postgres.GetTableSchema |
| 65 | + |
| 66 | +Get the schema of a table in a PostgreSQL database. |
| 67 | + |
| 68 | +<TabbedCodeBlock |
| 69 | + tabs={[ |
| 70 | + { |
| 71 | + label: "Call the Tool", |
| 72 | + content: { |
| 73 | + Python: [ |
| 74 | + "/examples/integrations/toolkits/postgres/get_table_schema_example_call_tool.py", |
| 75 | + ], |
| 76 | + JavaScript: ["/examples/integrations/toolkits/postgres/get_table_schema_example_call_tool.js"], |
| 77 | + }, |
| 78 | + } |
| 79 | + ]} |
| 80 | +/> |
| 81 | +## Postgres.ExecuteQuery |
| 82 | + |
| 83 | +<TabbedCodeBlock |
| 84 | + tabs={[ |
| 85 | + { |
| 86 | + label: "Call the Tool", |
| 87 | + content: { |
| 88 | + Python: [ |
| 89 | + "/examples/integrations/toolkits/postgres/execute_query_example_call_tool.py", |
| 90 | + ], |
| 91 | + JavaScript: ["/examples/integrations/toolkits/postgres/execute_query_example_call_tool.js"], |
| 92 | + }, |
| 93 | + } |
| 94 | + ]} |
| 95 | +/> |
| 96 | + |
| 97 | +Execute a query on a PostgreSQL database. Be sure that your agent runs the `Postgres.DiscoverTables` and `Postgres.GetTableSchema` tools before executing a query. |
0 commit comments