From 7172d978e98c50b3eef99cd8eb6510d1619c4012 Mon Sep 17 00:00:00 2001 From: David Gomes Date: Sun, 17 Nov 2024 12:40:01 +0100 Subject: [PATCH] some code cleanup --- .../templates/crewai/tools/neon_tool.py | 69 +------------------ .../web_researcher/src/tools/neon_tool.py | 2 +- 2 files changed, 3 insertions(+), 68 deletions(-) diff --git a/agentstack/templates/crewai/tools/neon_tool.py b/agentstack/templates/crewai/tools/neon_tool.py index 76d5e5c..1ede393 100644 --- a/agentstack/templates/crewai/tools/neon_tool.py +++ b/agentstack/templates/crewai/tools/neon_tool.py @@ -8,70 +8,5 @@ NEON_API_KEY = os.getenv('NEON_API_KEY') neon_client = Neon(api_key=NEON_API_KEY) -@tool("Create Project") -def create_project(project_name: str) -> str: - """ - Creates a new Neon project. - Args: - project_name: Name of the project to create - Returns: - Project ID and status message - """ - try: - project = neon_client.projects.create(name=project_name) - return f"Project created successfully. Project ID: {project.id}" - except Exception as e: - return f"Failed to create project: {str(e)}" - -@tool("Create Database") -def create_database(project_id: str, database_name: str) -> str: - """ - Creates a new database in specified Neon project. - Args: - project_id: ID of the project - database_name: Name of the database to create - Returns: - Status message about database creation - """ - try: - result = neon_client.databases.create( - project_id=project_id, - name=database_name - ) - return f"Database {database_name} created successfully" - except Exception as e: - return f"Failed to create database: {str(e)}" - -@tool("List Databases") -def list_databases(project_id: str) -> str: - """ - Lists all databases in specified Neon project. - Args: - project_id: ID of the project - Returns: - List of database names - """ - try: - databases = neon_client.databases.list(project_id=project_id) - return "\n".join([db.name for db in databases]) - except Exception as e: - return f"Failed to list databases: {str(e)}" - -@tool("Delete Database") -def delete_database(project_id: str, database_name: str) -> str: - """ - Deletes a database from specified Neon project. - Args: - project_id: ID of the project - database_name: Name of the database to delete - Returns: - Status message about database deletion - """ - try: - neon_client.databases.delete( - project_id=project_id, - name=database_name - ) - return f"Database {database_name} deleted successfully" - except Exception as e: - return f"Failed to delete database: {str(e)}" +# TODO: Should I duplicate this from the web_researcher example? Or is it +# possible to somehow have the web_researcher example import this? \ No newline at end of file diff --git a/examples/web_researcher/src/tools/neon_tool.py b/examples/web_researcher/src/tools/neon_tool.py index 4c28b70..b305fc5 100644 --- a/examples/web_researcher/src/tools/neon_tool.py +++ b/examples/web_researcher/src/tools/neon_tool.py @@ -13,7 +13,7 @@ @tool("Create Neon Project and Database") def create_database(project_name: str) -> str: """ - Creates a new Neon project. + Creates a new Neon project. (this takes less than 500ms) Args: project_name: Name of the project to create Returns: