From 79de8353c0dd54805edf69379669bc5ea6f1d623 Mon Sep 17 00:00:00 2001 From: Arpit Roopchandani <17565234+whoisarpit@users.noreply.github.com> Date: Fri, 11 Apr 2025 16:52:42 +0800 Subject: [PATCH 1/3] Enhance FindTextTool with recursive search option and improve json_schema specification. --- patchwork/common/tools/grep_tool.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/patchwork/common/tools/grep_tool.py b/patchwork/common/tools/grep_tool.py index d5573ba23..02a583044 100644 --- a/patchwork/common/tools/grep_tool.py +++ b/patchwork/common/tools/grep_tool.py @@ -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. @@ -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", @@ -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!" @@ -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()] @@ -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}': \n" + total_file_matches += f"\n {len(matches)} Pattern matches found in '{path_str}': \n" return total_file_matches From 2ecb5b3ee2806dbad712b0ca66acc7b9ae799594 Mon Sep 17 00:00:00 2001 From: Arpit Roopchandani <17565234+whoisarpit@users.noreply.github.com> Date: Fri, 11 Apr 2025 17:11:06 +0800 Subject: [PATCH 2/3] Bump version to 0.0.121 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 50858a014..2b232bf6f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "patchwork-cli" -version = "0.0.120" +version = "0.0.121" description = "" authors = ["patched.codes"] license = "AGPL" From 43e15a8f7c5a05107b47939e9e3876e796b1d32e Mon Sep 17 00:00:00 2001 From: "patched.codes[bot]" <298395+patched.codes[bot]@users.noreply.github.com> Date: Fri, 11 Apr 2025 09:18:43 +0000 Subject: [PATCH 3/3] Patched patchwork/steps/ManageEngineAgent/README.md --- patchwork/steps/ManageEngineAgent/README.md | 54 +++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 patchwork/steps/ManageEngineAgent/README.md diff --git a/patchwork/steps/ManageEngineAgent/README.md b/patchwork/steps/ManageEngineAgent/README.md new file mode 100644 index 000000000..16298d9a4 --- /dev/null +++ b/patchwork/steps/ManageEngineAgent/README.md @@ -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.