Skip to content
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

AgenticLLM Step #1155

Merged
merged 10 commits into from
Jan 6, 2025
Merged
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
43 changes: 27 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,17 @@ jobs:

- name: AutoFix Patchwork
run: |
poetry run patchwork AutoFix --log debug \
source .venv/bin/activate
patchwork AutoFix --log debug \
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
--force_pr_creation \
--disable_telemetry

- name: Dependency Upgrade
run: |
poetry run patchwork DependencyUpgrade --log debug \
source .venv/bin/activate
patchwork DependencyUpgrade --log debug \
--libraries_api_key=${{ secrets.LIBRARIES_KEY }} \
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
Expand All @@ -124,6 +126,8 @@ jobs:
--disable_telemetry

rag-test:
# disabled because this currently takes too long
if: false
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand Down Expand Up @@ -158,14 +162,15 @@ jobs:
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --only main --extras rag

# disabled because this currently takes too long
# - name: Resolve issue
# run: |
# poetry run patchwork ResolveIssue --log debug \
# --patched_api_key=${{ secrets.PATCHED_API_KEY }} \
# --github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
# --issue_url=https://github.com/patched-codes/patchwork/issues/1039 \
# --disable_telemetry
- name: Resolve issue
run: |
source .venv/bin/activate
patchwork ResolveIssue --log debug \
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
--issue_url=https://github.com/patched-codes/patchwork/issues/1129 \
--disable_telemetry
--max_llm_calls=10

main-test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -204,46 +209,52 @@ jobs:

- name: PR Review
run: |
poetry run patchwork PRReview --log debug \
source .venv/bin/activate
patchwork PRReview --log debug \
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
--pr_url=https://github.com/patched-codes/patchwork/pull/${{ steps.findPr.outputs.number }} \
--disable_telemetry

- name: Generate Docstring
run: |
poetry run patchwork GenerateDocstring --log debug \
source .venv/bin/activate
patchwork GenerateDocstring --log debug \
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
--base_path=tests/cicd/generate_docstring \
--disable_telemetry

- name : Generate Diagram
run: |
poetry run patchwork GenerateDiagram --log debug \
source .venv/bin/activate
patchwork GenerateDiagram --log debug \
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
--folder_path=patchwork/steps \
--disable_telemetry

- name: Generate UnitTests
run: |
poetry run patchwork GenerateUnitTests --log debug \
source .venv/bin/activate
patchwork GenerateUnitTests --log debug \
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
--folder_path=tests/cicd/generate_docstring \
--disable_telemetry

- name: Generate Code Usage Example
run: |
poetry run patchwork GenerateCodeUsageExample --log debug \
source .venv/bin/activate
patchwork GenerateCodeUsageExample --log debug \
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
--folder_path=tests/cicd/generate_docstring \
--disable_telemetry

- name: Generate README
run: |
source .venv/bin/activate
# Specify the parent folder you want to check
PARENT_FOLDER="./patchwork/steps"
# Command to run if README.md is not found
Expand All @@ -256,7 +267,7 @@ jobs:
# Convert to a Git-friendly branch name: replace spaces with underscores, remove slashes, etc.
branch_name=$(echo "$base_name" | sed -e 's/[^a-zA-Z0-9]/_/g' -e 's/__*/_/g' -e 's/^_//g' -e 's/_$//g')

poetry run patchwork GenerateREADME --log debug \
patchwork GenerateREADME --log debug \
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
--filter=*.py \
Expand Down
98 changes: 49 additions & 49 deletions patchwork/common/client/llm/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,22 @@ def __adapt_input_messages(self, messages: Iterable[ChatCompletionMessageParam])
return new_messages

def __adapt_chat_completion_request(
self,
messages: Iterable[ChatCompletionMessageParam],
model: str,
frequency_penalty: Optional[float] | NotGiven = NOT_GIVEN,
logit_bias: Optional[Dict[str, int]] | NotGiven = NOT_GIVEN,
logprobs: Optional[bool] | NotGiven = NOT_GIVEN,
max_tokens: Optional[int] | NotGiven = NOT_GIVEN,
n: Optional[int] | NotGiven = NOT_GIVEN,
presence_penalty: Optional[float] | NotGiven = NOT_GIVEN,
response_format: completion_create_params.ResponseFormat | NotGiven = NOT_GIVEN,
stop: Union[Optional[str], List[str]] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
tool_choice: ChatCompletionToolChoiceOptionParam | NotGiven = NOT_GIVEN,
top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
top_p: Optional[float] | NotGiven = NOT_GIVEN,
self,
messages: Iterable[ChatCompletionMessageParam],
model: str,
frequency_penalty: Optional[float] | NotGiven = NOT_GIVEN,
logit_bias: Optional[Dict[str, int]] | NotGiven = NOT_GIVEN,
logprobs: Optional[bool] | NotGiven = NOT_GIVEN,
max_tokens: Optional[int] | NotGiven = NOT_GIVEN,
n: Optional[int] | NotGiven = NOT_GIVEN,
presence_penalty: Optional[float] | NotGiven = NOT_GIVEN,
response_format: completion_create_params.ResponseFormat | NotGiven = NOT_GIVEN,
stop: Union[Optional[str], List[str]] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
tool_choice: ChatCompletionToolChoiceOptionParam | NotGiven = NOT_GIVEN,
top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
top_p: Optional[float] | NotGiven = NOT_GIVEN,
):
system: Union[str, Iterable[TextBlockParam]] | NotGiven = NOT_GIVEN
adapted_messages = self.__adapt_input_messages(messages)
Expand Down Expand Up @@ -208,22 +208,22 @@ def is_model_supported(self, model: str) -> bool:
return model in self.__definitely_allowed_models or model.startswith(self.__allowed_model_prefix)

def is_prompt_supported(
self,
messages: Iterable[ChatCompletionMessageParam],
model: str,
frequency_penalty: Optional[float] | NotGiven = NOT_GIVEN,
logit_bias: Optional[Dict[str, int]] | NotGiven = NOT_GIVEN,
logprobs: Optional[bool] | NotGiven = NOT_GIVEN,
max_tokens: Optional[int] | NotGiven = NOT_GIVEN,
n: Optional[int] | NotGiven = NOT_GIVEN,
presence_penalty: Optional[float] | NotGiven = NOT_GIVEN,
response_format: completion_create_params.ResponseFormat | NotGiven = NOT_GIVEN,
stop: Union[Optional[str], List[str]] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
tool_choice: ChatCompletionToolChoiceOptionParam | NotGiven = NOT_GIVEN,
top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
top_p: Optional[float] | NotGiven = NOT_GIVEN,
self,
messages: Iterable[ChatCompletionMessageParam],
model: str,
frequency_penalty: Optional[float] | NotGiven = NOT_GIVEN,
logit_bias: Optional[Dict[str, int]] | NotGiven = NOT_GIVEN,
logprobs: Optional[bool] | NotGiven = NOT_GIVEN,
max_tokens: Optional[int] | NotGiven = NOT_GIVEN,
n: Optional[int] | NotGiven = NOT_GIVEN,
presence_penalty: Optional[float] | NotGiven = NOT_GIVEN,
response_format: completion_create_params.ResponseFormat | NotGiven = NOT_GIVEN,
stop: Union[Optional[str], List[str]] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
tool_choice: ChatCompletionToolChoiceOptionParam | NotGiven = NOT_GIVEN,
top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
top_p: Optional[float] | NotGiven = NOT_GIVEN,
) -> int:
model_limit = self.__get_model_limit(model)
input_kwargs = self.__adapt_chat_completion_request(
Expand Down Expand Up @@ -252,27 +252,27 @@ def is_prompt_supported(
return model_limit - message_token_count.input_tokens

def truncate_messages(
self, messages: Iterable[ChatCompletionMessageParam], model: str
self, messages: Iterable[ChatCompletionMessageParam], model: str
) -> Iterable[ChatCompletionMessageParam]:
return self._truncate_messages(self, messages, model)

def chat_completion(
self,
messages: Iterable[ChatCompletionMessageParam],
model: str,
frequency_penalty: Optional[float] | NotGiven = NOT_GIVEN,
logit_bias: Optional[Dict[str, int]] | NotGiven = NOT_GIVEN,
logprobs: Optional[bool] | NotGiven = NOT_GIVEN,
max_tokens: Optional[int] | NotGiven = NOT_GIVEN,
n: Optional[int] | NotGiven = NOT_GIVEN,
presence_penalty: Optional[float] | NotGiven = NOT_GIVEN,
response_format: completion_create_params.ResponseFormat | NotGiven = NOT_GIVEN,
stop: Union[Optional[str], List[str]] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
tool_choice: ChatCompletionToolChoiceOptionParam | NotGiven = NOT_GIVEN,
top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
top_p: Optional[float] | NotGiven = NOT_GIVEN,
self,
messages: Iterable[ChatCompletionMessageParam],
model: str,
frequency_penalty: Optional[float] | NotGiven = NOT_GIVEN,
logit_bias: Optional[Dict[str, int]] | NotGiven = NOT_GIVEN,
logprobs: Optional[bool] | NotGiven = NOT_GIVEN,
max_tokens: Optional[int] | NotGiven = NOT_GIVEN,
n: Optional[int] | NotGiven = NOT_GIVEN,
presence_penalty: Optional[float] | NotGiven = NOT_GIVEN,
response_format: completion_create_params.ResponseFormat | NotGiven = NOT_GIVEN,
stop: Union[Optional[str], List[str]] | NotGiven = NOT_GIVEN,
temperature: Optional[float] | NotGiven = NOT_GIVEN,
tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
tool_choice: ChatCompletionToolChoiceOptionParam | NotGiven = NOT_GIVEN,
top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
top_p: Optional[float] | NotGiven = NOT_GIVEN,
) -> ChatCompletion:
input_kwargs = self.__adapt_chat_completion_request(
messages=messages,
Expand Down
7 changes: 1 addition & 6 deletions patchwork/common/client/patched.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,7 @@ def finish_record_patchflow_run(self, id: int, patchflow: str, repo: Repo, outpu
response = self._post(
url=self.url + "/v1/patchwork/",
headers={"Authorization": f"Bearer {self.access_token}"},
json={
"id": id,
"url": repo.remotes.origin.url,
"patchflow": patchflow,
"outputs": outputs
},
json={"id": id, "url": repo.remotes.origin.url, "patchflow": patchflow, "outputs": outputs},
)

if response is None:
Expand Down
Loading
Loading