Skip to content

PatchWork GenerateREADME #1616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: patchwork-resolveissue-mainImproveApiErrorHandling
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions patchwork/steps/DatabaseAgent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# DatabaseAgent Module Documentation

The `DatabaseAgent` module is designed to execute database query operations utilizing an agentic strategy involving large language models and tools. This module primarily serves as an interface between a database and a language model to facilitate data retrieval and task execution.

## Overview

The module contains several key components:

- **DatabaseAgent**: The main class that configures and executes the database agent strategy.
- **DatabaseAgentInputs & DatabaseAgentOutputs**: Typed dictionaries that define the expected input and output structures for the `DatabaseAgent`.
- **Initialization**: An empty `__init__.py` making the module importable.

## Code Components

### File: DatabaseAgent.py

#### Primary Class: `DatabaseAgent`

The `DatabaseAgent` class inherits from the `Step` class and is responsible for executing an agentic strategy using language models to perform database queries.

#### Inputs

- **prompt_value**: A dictionary for dynamic content in the prompt.
- **task**: A string template rendered with `prompt_value` to define tasks.
- **db_dialect**: The database dialect/engine to use.
- **llm_client**: Initializes a language model client using the asynchronous `AioLlmClient`.
- **task configuration**: Configures the reasoning strategy of the agent, leveraging an AgentConfig.

#### Outputs

- Returns a dictionary containing the execution result and usage metrics of the agentic strategy. Specifically, it provides:
- **request_tokens**: The number of tokens sent in the request.
- **response_tokens**: The number of tokens received from the response.

#### Usage

This class would be instantiated with specific database and task parameters and then execute its `run()` method to perform operations, logging the data execution tasks and associated metrics.

### File: typed.py

#### Classes: `DatabaseAgentInputs` and `DatabaseAgentOutputs`

- **DatabaseAgentInputs**: Defines possible inputs with required and optional fields, including database connection details, API keys, and example data.

- **DatabaseAgentOutputs**: Structures the expected output, primarily focusing on token usage during the data execution process.

### File: __init__.py

This file is an empty initializer to allow importing of the module components.

## Use Cases

The `DatabaseAgent` is intended for integration in larger systems where automated and intelligent database querying is required. Researchers and developers could employ this tool for tasks demanding dynamic, context-aware interactions with databases, possibly for analytics, reporting, or data mining functions.

Overall, this module simplifies the process of querying databases by employing a smart agent that abstracts interactions through structured prompts and agent strategies.