Skip to content

PatchWork GenerateDocstring #1577

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 10 commits into
base: main
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
4 changes: 2 additions & 2 deletions patchwork/steps/AgenticLLMV2/AgenticLLMV2.py
Original file line number Diff line number Diff line change
@@ -18,15 +18,15 @@ def __init__(self, inputs):
base_path = str(Path.cwd())
self.conversation_limit = int(inputs.get("max_agent_calls", 1))
self.agentic_strategy = AgenticStrategyV2(
model="claude-3-5-sonnet-latest",
model=inputs.get("strategy_model", "claude-3-5-sonnet-latest"),
llm_client=AioLlmClient.create_aio_client(inputs),
template_data=inputs.get("prompt_value", {}),
system_prompt_template=inputs.get("system_prompt", "Summarise from our previous conversation"),
user_prompt_template=inputs.get("user_prompt"),
agent_configs=[
AgentConfig(
name="Assistant",
model="claude-3-7-sonnet-latest",
model=inputs.get("agent_model", "claude-3-7-sonnet-latest"),
tool_set=Tool.get_tools(path=base_path),
system_prompt=inputs.get("agent_system_prompt"),
)
25 changes: 24 additions & 1 deletion patchwork/steps/AgenticLLMV2/typed.py
Original file line number Diff line number Diff line change
@@ -9,9 +9,32 @@ class AgenticLLMV2Inputs(TypedDict, total=False):
system_prompt: str
user_prompt: str
max_agent_calls: Annotated[int, StepTypeConfig(is_config=True)]
anthropic_api_key: str
strategy_model: str
agent_model: str
agent_system_prompt: str
example_json: str
openai_api_key: Annotated[
str,
StepTypeConfig(
is_config=True, or_op=["patched_api_key", "google_api_key", "client_is_gcp", "anthropic_api_key"]
),
]
anthropic_api_key: Annotated[
str,
StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "client_is_gcp", "openai_api_key"]),
]
google_api_key: Annotated[
str,
StepTypeConfig(
is_config=True, or_op=["patched_api_key", "openai_api_key", "client_is_gcp", "anthropic_api_key"]
),
]
client_is_gcp: Annotated[
str,
StepTypeConfig(
is_config=True, or_op=["patched_api_key", "openai_api_key", "anthropic_api_key", "google_api_key"]
),
]


class AgenticLLMV2Outputs(TypedDict):
12 changes: 7 additions & 5 deletions patchwork/steps/GitHubAgent/GitHubAgent.py
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ def __init__(self, inputs):
model="claude-3-5-sonnet-latest",
llm_client=AioLlmClient.create_aio_client(inputs),
template_data=dict(),
system_prompt_template=f"""\
system_prompt_template="""\
Please summarise the conversation given and provide the result in the structure that is asked of you.
""",
user_prompt_template=f"""\
@@ -34,15 +34,17 @@ def __init__(self, inputs):
AgentConfig(
name="Assistant",
model="gemini-2.0-flash",
tool_set=dict(github_tool=GitHubTool(base_path, inputs["github_api_token"])),
tool_set=dict(github_tool=GitHubTool(base_path, inputs["github_api_key"])),
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.
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.
Your `gh` app has already been authenticated.
""",
)
],
example_json=inputs.get("example_json"),
example_json=inputs.get(
"example_json", '{"summary_of_actions": "1. Retrieved the list of repositories. 2. ..."}'
),
)

def run(self) -> dict:
4 changes: 3 additions & 1 deletion patchwork/steps/GitHubAgent/typed.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
from typing_extensions import Annotated, Any, Dict, TypedDict
from typing_extensions import Annotated, Any, Dict, Optional, TypedDict

from patchwork.common.utils.step_typing import StepTypeConfig


class __GitHubAgentRequiredInputs(TypedDict):
github_api_key: str
task: str


class GitHubAgentInputs(__GitHubAgentRequiredInputs, total=False):
base_path: str
prompt_value: Dict[str, Any]
max_llm_calls: Annotated[int, StepTypeConfig(is_config=True)]
example_json: str
openai_api_key: Annotated[
str,
StepTypeConfig(
50 changes: 25 additions & 25 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.121"
version = "0.0.122"
description = ""
authors = ["patched.codes"]
license = "AGPL"
34 changes: 34 additions & 0 deletions tests/cicd/generate_docstring/cpp_test_file.cpp
Original file line number Diff line number Diff line change
@@ -6,11 +6,27 @@


template<typename T>
/**
* Computes the sum of two values.
* This function adds two parameters of a generic type and returns their sum.
*
* @param a The first value to be added.
* @param b The second value to be added.
* @return The sum of the two values.
*/
T a_plus_b(T a, T b) {
return a + b;
}


/**
* Executes an SQL query on a given SQLite database and retrieves the results as a vector of vector of strings.
* Each inner vector represents a row in the query result, with each element being a string representation of the column values.
*
* @param db Pointer to the SQLite database connection.
* @param query The SQL query string to be executed on the database.
* @return A vector of vectors containing the query results. Each inner vector represents a row, and each element within it represents a column value, converted to a string. If preparation of the statement fails, returns an empty vector.
*/
std::vector<std::vector<std::string>> sqlite(sqlite3* db, const std::string& query) {
std::vector<std::vector<std::string>> results;
sqlite3_stmt* stmt;
@@ -38,6 +54,18 @@ std::vector<std::vector<std::string>> sqlite(sqlite3* db, const std::string& que


template<typename T, typename F>
/**
* Compares two items using a specified key mapping function and returns an integer
* to indicate their relative order. The function applies the provided key mapping
* function to both items, compares the resultant values and returns -1 if the first
* item is less than the second, 1 if it's greater, or 0 if they are equal.
*
* @param key_map Function or functor to map an item to a comparable value.
* @param item1 The first item to be compared.
* @param item2 The second item to be compared.
* @return An integer indicating the comparison result: -1 if item1 < item2,
* 1 if item1 > item2, or 0 if item1 equals item2.
*/
int compare(F key_map, const T& item1, const T& item2) {
auto val1 = key_map(item1);
auto val2 = key_map(item2);
@@ -48,6 +76,12 @@ int compare(F key_map, const T& item1, const T& item2) {
}


/**
* Generates a random string consisting of uppercase and lowercase alphabets of a specified length.
*
* @param length The length of the random string to generate.
* @return A random string composed of alphabets with the specified length.
*/
std::string random_alphabets(int length) {
static const std::string chars =
"abcdefghijklmnopqrstuvwxyz"
Loading