Skip to content

PatchWork GenerateREADME #1573

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 3 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
26 changes: 18 additions & 8 deletions patchwork/common/tools/grep_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def json_schema(self) -> dict:
"name": "find_text",
"description": f"""\
Tool to find text in a file or files in a directory using a pattern based on the Unix shell style.
The current working directory is always {self.__working_dir}.
The current working directory is always {self.__working_dir}.
The path provided should either be absolute or relative to the current working directory.

This tool will match each line of the file with the provided pattern and prints the line number and the line content.
Expand All @@ -135,19 +135,26 @@ def json_schema(self) -> dict:
[!seq] matches any char not in seq

Example:
* '*macs' will match the file '.emacs'
* '*.py' will match all files with the '.py' extension
* 'class T*' will match the line 'class Team:' but not ' class Team:' because the second line is indented.
* '*var1: str' will match the line ' var1: str' but not 'var1: str = "test"'
* '*class Team*' will match both the lines 'class Team:' and 'class TeamMember(BaseTeam):'
* 'TeamMember' will not match 'class TeamMember:' because the pattern should match the entire line

""",
"type": "string",
},
"path": {
"description": """\
The path to the file to find text in.
The path to the file to find text in.
If not given, will search all file content in the current working directory.
If the path is a directory, will search all file content in the directory.
""",
"type": "string",
},
"recursive": {
"description": "Set as False to only search specified file or immediate files in the specified directory. Default is True.",
"type": "boolean",
},
"is_case_sensitive": {
"description": "Whether the pattern should be case-sensitive.",
"type": "boolean",
Expand All @@ -162,6 +169,7 @@ def execute(
pattern: Optional[str] = None,
path: Optional[Path] = None,
is_case_sensitive: bool = False,
recursive: bool = True,
) -> str:
if pattern is None:
return "`pattern` argument is required!"
Expand All @@ -176,12 +184,14 @@ def execute(
try:
path = Path(path).resolve()
except FileNotFoundError:
return f"`path` does not exist"
return "`path` does not exist"
if not path.is_relative_to(self.__working_dir):
return f"Path must be relative to working dir {self.__working_dir}"

if path.is_file():
paths = [path]
elif recursive:
paths = list(set(p for p in path.rglob("*") if p.is_file()))
else:
paths = [p for p in path.iterdir() if p.is_file()]

Expand All @@ -200,17 +210,17 @@ def execute(
content = f"Line {i + 1}: {self.__CHAR_LIMIT_TEXT}"

file_matches[str(path)].append(content)
except Exception as e:
except Exception:
pass

total_file_matches = ""
for path_str, matches in file_matches.items():
total_file_matches += f"\nPattern matches found in '{path}':\n" + "\n".join(matches)
total_file_matches += f"\nPattern matches found in '{path_str}':\n" + "\n".join(matches)

if len(total_file_matches) <= 5000:
return total_file_matches

total_file_matches = ""
for path_str, matches in file_matches.items():
total_file_matches += f"\n {len(matches)} Pattern matches found in '{path}': <TRUNCATED>\n"
total_file_matches += f"\n {len(matches)} Pattern matches found in '{path_str}': <TRUNCATED>\n"
return total_file_matches
54 changes: 54 additions & 0 deletions patchwork/steps/ManageEngineAgent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# ManageEngineAgent Documentation

## Overview

The `ManageEngineAgent` code provides an interface between a chatbot agent and the ManageEngine ServiceDesk API, utilizing various API keys for OpenAI, Anthropic, and Google as alternatives to execute large language model (LLM) interactions. This code is structured to define the required inputs and expected outputs, focusing on facilitating automated interactions with ManageEngine's ServiceDesk, which is especially useful for software developers aiding program managers in managing tickets and service desk tasks programmatically.

## Files and Descriptions

### 1. `typed.py`
This file defines the input and output types for the ManageEngineAgent, ensuring type safety and clarity of required and optional fields.

#### Inputs
- **`zoho_access_token` (str)**: Required for authorization with Zoho.
- **`user_prompt` (str)**: Required prompt for user input to the agent.
- **`prompt_value` (Dict[str, Any])**: Dictionary containing values that may be needed for rendering templated user prompts.
- **Optional Inputs**:
- `max_agent_calls` (int)
- `openai_api_key` (str)
- `anthropic_api_key` (str)
- `google_api_key` (str)
- `system_prompt` (str)
- `example_json` (Dict)

#### Outputs
- **`conversation_history` (List[Dict])**
- **`tool_records` (List[Dict])**
- **`request_tokens` (int)**
- **`response_tokens` (int)**

### 2. `__init__.py`
This init file currently serves as a placeholder and does not contain any code.

### 3. `ManageEngineAgent.py`
This file contains the implementation of the `ManageEngineAgent` class, providing the operational logic to interface with the ManageEngine API using the defined input and output structures.

#### Components
- **Initialization**:
- Validates required inputs (`zoho_access_token`, `user_prompt`).
- Sets headers for API requests using the Zoho access token.
- Configures an AI client (LLM client) and the agent strategy.

- **Agent Strategy**:
- Provides interaction with ManageEngine to retrieve, create, or modify service desk tickets.
- Uses `AgenticStrategyV2` to define models and tool sets.

- **Methods**:
- **`run()`**: Executes the agent strategy and returns the result along with usage statistics.

## How to Use
1. **Input Configuration**: Populate `ManageEngineAgentInputs` with the required fields like `zoho_access_token` and `user_prompt`.
2. **Run the Agent**: Instantiate the `ManageEngineAgent` with the inputs and call the `run()` method to perform the desired operations.
3. **Extract Results**: Review the output from `ManageEngineAgentOutputs` to analyze the conversation history and API interaction results.

This setup provides automation and intelligent processing for managing service desk operations, making it a valuable tool for software development and support teams.
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.120"
version = "0.0.121"
description = ""
authors = ["patched.codes"]
license = "AGPL"
Expand Down