Skip to content

PatchWork GenerateREADME #1638

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 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
49 changes: 49 additions & 0 deletions patchwork/common/tools/git_tool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from __future__ import annotations

import os
import subprocess

from patchwork.common.tools.tool import Tool


class GitTool(Tool, tool_name="git_tool", abc_register=False):
def __init__(self, path: str):
super().__init__()
self.path = path

@property
def json_schema(self) -> dict:
return {
"name": "git_tool",
"description": """\
Access to the Git CLI, the command is also `git` all args provided are used as is.
""",
"input_schema": {
"type": "object",
"properties": {
"args": {
"type": "array",
"items": {"type": "string"},
"description": """
The args to run `git` command with.
E.g.
[\"commit\", \"-m\", \"A commit message\"] to commit changes with a commit message.
[\"add\", \".\"] to stage all changed files.
""",
}
},
"required": ["args"],
},
}

def execute(self, args: list[str]) -> str:
env = os.environ.copy()
p = subprocess.run(
["git", *args],
env=env,
cwd=self.path,
text=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
return p.stdout
2 changes: 1 addition & 1 deletion patchwork/common/tools/github_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from patchwork.common.tools.tool import Tool


class GitHubTool(Tool, tool_name="github_tool"):
class GitHubTool(Tool, tool_name="github_tool", abc_register=False):
def __init__(self, path: str, gh_token: str):
super().__init__()
self.path = path
Expand Down
6 changes: 5 additions & 1 deletion patchwork/steps/GitHubAgent/GitHubAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
AgentConfig,
AgenticStrategyV2,
)
from patchwork.common.tools.git_tool import GitTool
from patchwork.common.tools.github_tool import GitHubTool
from patchwork.common.utils.utils import mustache_render
from patchwork.step import Step
Expand Down Expand Up @@ -34,7 +35,10 @@ def __init__(self, inputs):
AgentConfig(
name="Assistant",
model="gemini-2.0-flash",
tool_set=dict(github_tool=GitHubTool(base_path, inputs["github_api_key"])),
tool_set=dict(
github_tool=GitHubTool(base_path, inputs["github_api_key"]),
git_tool=GitTool(base_path),
),
system_prompt="""\
You are a senior software developer helping the program manager to obtain some data from GitHub.
You can access github through the `gh` CLI app.
Expand Down
50 changes: 50 additions & 0 deletions patchwork/steps/ManageEngineAgent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# ManageEngineAgent Code Documentation

## Overview

The `ManageEngineAgent` module is part of a larger framework and facilitates interactions with the ManageEngine ServiceDesk API by utilizing advanced AI models to assist in ticket management through API requests. This implementation relies on a strategic AI-driven approach to handle conversations and API interactions, aiming to streamline service desk operations.

## File Structure

- **typed.py**: Defines input and output types for the `ManageEngineAgent` using Python's `TypedDict` for structured data annotations.
- **__init__.py**: An empty initialization file that allows the directory to be treated as a package.
- **ManageEngineAgent.py**: The core of the module where the `ManageEngineAgent` class is implemented, leveraging AI and API tools for efficient service desk management.

## Inputs

Defined in `typed.py` as part of the `ManageEngineAgentInputs` class:

### Required

- `zoho_access_token`: A string representing the Zoho authentication token to authorize API requests.
- `user_prompt`: A string to guide the AI interaction and provide context for the tasks to be accomplished.
- `prompt_value`: A dictionary containing dynamic information to be used in the user prompt.

### Optional

- `max_agent_calls`: An integer that limits the number of API calls during a session.
- `openai_api_key`, `anthropic_api_key`, `google_api_key`: Keys that specify which AI model to use for generating conversational and strategic responses, considering mutual exclusivity.
- `system_prompt`: An optional string to refine the AI's overarching conversation context.
- `example_json`: An optional dictionary for example data used in training or AI-response generation.

## Outputs

Defined in `typed.py` as part of the `ManageEngineAgentOutputs` class:

- `conversation_history`: A list of dictionaries representing the history of the AI-driven conversations.
- `tool_records`: A list of dictionaries documenting the interactions with the ManageEngine API.
- `request_tokens`: An integer indicating the number of tokens used in requests.
- `response_tokens`: An integer indicating the number of tokens generated in responses.

## Key Features

- **AI-Driven API Interactions**: The `ManageEngineAgent` uses a state-of-the-art conversational AI model to automate interactions with the ManageEngine ServiceDesk API.
- **Configurable Strategy**: Offers flexibility in selecting AI models and configuring API call limits to suit different operational needs.
- **Template-Driven Input Handling**: Utilizes `mustache_render` for dynamic user prompts and system messages, ensuring context-relevant interactions.

## Example Use Case

- **Automating Service Desk Tasks**: Integrate this agent into an IT service workflow to automate tasks such as ticket retrieval, updates, and creation via ManageEngine's ServiceDesk API.
- **AI-Augmented Decision Support**: Use configured conversation strategies to provide AI recommendations alongside operational reports to decision-makers.

By structuring the code using Python’s `TypedDict` and leveraging advanced AI strategies, the `ManageEngineAgent` module provides robust support for intelligent service management operations.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "patchwork-cli"
version = "0.0.123"
version = "0.0.124"
description = ""
authors = ["patched.codes"]
license = "AGPL"
Expand Down