From afbaae55cdcaa99076660822ca30089e216f8bcd Mon Sep 17 00:00:00 2001 From: bgrenon Date: Wed, 15 Jan 2025 23:49:16 -0400 Subject: [PATCH 1/2] docs: adding Neon as database tool --- docs/tools/community.mdx | 3 ++ docs/tools/tool/neon.mdx | 61 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 docs/tools/tool/neon.mdx diff --git a/docs/tools/community.mdx b/docs/tools/community.mdx index 62f506c2..efd3f5da 100644 --- a/docs/tools/community.mdx +++ b/docs/tools/community.mdx @@ -18,6 +18,9 @@ description: 'AgentStack tools from community contributors' - [Mem0](/tools/tool/mem0) +## Database Tools +- [Neon](/tools/tool/neon) + ## Code Execution - [Open Interpreter](/tools/tool/open-interpreter) diff --git a/docs/tools/tool/neon.mdx b/docs/tools/tool/neon.mdx new file mode 100644 index 00000000..ba960ab0 --- /dev/null +++ b/docs/tools/tool/neon.mdx @@ -0,0 +1,61 @@ +--- +title: Neon +description: Postgres for agents +--- + +## Description +Neon is a serverless Postgres platform that lets your agents create and manage databases on demand. It supports ephemeral or long-lived Postgres instances for storing structured data. + +## Prerequisites +1. A Neon account. If you do not have one, sign up at [Neon](https://neon.tech). +2. Get your API key from the [Neon Console](https://console.neon.tech/app/settings/api-keys). +3. The tool will automatically install required dependencies: + - neon-api + - psycopg2-binary + +## Installation + +```bash +agentstack tools add neon +``` + +## Configuration +```bash +NEON_API_KEY=... +``` + +## Available Tools +Out of the box, these tools are ready to use: + +1. **`create_database`** + Creates a new Neon project and returns a connection URI. Default settings create a database called `neondb` with the `neondb_owner` role. + + The agent's response to errors will depend on its reasoning about the specific situation. It may retry a failed action, but this behavior is probabilistic rather than deterministic. + +2. **`execute_sql_ddl`** + Run schema commands (e.g., `CREATE TABLE`) using a connection URI and SQL command. Transactions are automatically handled. + +3. **`run_sql_query`** + Run data queries (e.g., `SELECT`, `INSERT`) using a connection URI and SQL query. Results are returned as formatted strings. + +## Using the Tools +Add the tools you need to your agent: +```python +@agent +def db_writer(self) -> Agent: + return Agent( + config=self.agents_config['db_writer'], + tools=[tools.create_database, tools.execute_sql_ddl, tools.run_sql_query], + verbose=True, + ) +``` + +For a complete example, see `AgentStack/examples/web_researcher` where an agent stores collected data in Postgres as part of a multi-agent workflow. + +## Usage Note +When you add the Neon tool to an existing project, all its tools will be added to every agent in the `agents.yaml` file. You may need to remove unused tools to keep each agent’s scope clear. + +## Customization +When you run `agentstack tools add neon`, the tool is added to your project as source code, not as a dependency. This means you can add more capabilities, like Neon's database [branching](https://neon.tech/docs/introduction/branching). + +For examples of how to implement additional tools, see the existing implementation in `neon_tool.py`. For more on Neon's API capabilities, refer to the [neon.tech/docs/reference/api-reference](https://neon.tech/docs/reference/api-reference). From c3cd65269cb2fb5603d8c8cc3da4e39df14547b8 Mon Sep 17 00:00:00 2001 From: bgrenon Date: Tue, 28 Jan 2025 15:12:43 -0400 Subject: [PATCH 2/2] changed tools usage also removed customization section --- docs/tools/tool/neon.mdx | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/docs/tools/tool/neon.mdx b/docs/tools/tool/neon.mdx index ba960ab0..21dc399d 100644 --- a/docs/tools/tool/neon.mdx +++ b/docs/tools/tool/neon.mdx @@ -2,7 +2,6 @@ title: Neon description: Postgres for agents --- - ## Description Neon is a serverless Postgres platform that lets your agents create and manage databases on demand. It supports ephemeral or long-lived Postgres instances for storing structured data. @@ -24,8 +23,8 @@ agentstack tools add neon NEON_API_KEY=... ``` -## Available Tools -Out of the box, these tools are ready to use: +## Available Actions +The following actions are automatically included when you add the Neon tool to your agent: 1. **`create_database`** Creates a new Neon project and returns a connection URI. Default settings create a database called `neondb` with the `neondb_owner` role. @@ -38,14 +37,14 @@ Out of the box, these tools are ready to use: 3. **`run_sql_query`** Run data queries (e.g., `SELECT`, `INSERT`) using a connection URI and SQL query. Results are returned as formatted strings. -## Using the Tools -Add the tools you need to your agent: +## Using the Tool +Add the Neon tool to your agent: ```python @agent def db_writer(self) -> Agent: return Agent( config=self.agents_config['db_writer'], - tools=[tools.create_database, tools.execute_sql_ddl, tools.run_sql_query], + tools=[*agentstack.tools['neon']], # Includes all Neon actions listed above verbose=True, ) ``` @@ -53,9 +52,4 @@ def db_writer(self) -> Agent: For a complete example, see `AgentStack/examples/web_researcher` where an agent stores collected data in Postgres as part of a multi-agent workflow. ## Usage Note -When you add the Neon tool to an existing project, all its tools will be added to every agent in the `agents.yaml` file. You may need to remove unused tools to keep each agent’s scope clear. - -## Customization -When you run `agentstack tools add neon`, the tool is added to your project as source code, not as a dependency. This means you can add more capabilities, like Neon's database [branching](https://neon.tech/docs/introduction/branching). - -For examples of how to implement additional tools, see the existing implementation in `neon_tool.py`. For more on Neon's API capabilities, refer to the [neon.tech/docs/reference/api-reference](https://neon.tech/docs/reference/api-reference). +When you add the Neon tool to an existing project, all its tools will be added to every agent in the `agents.yaml` file. You may need to remove unused tools to keep each agent's scope clear.