Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitamalinov committed Apr 24, 2024
1 parent 05c5049 commit b7cd82e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 25 deletions.
22 changes: 1 addition & 21 deletions services/gitauto_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
ISSUE_NUMBER_FORMAT,
)
from services.github.github_manager import (
commit_changes_to_remote_branch,
create_pull_request,
create_remote_branch,
get_installation_access_token,
Expand All @@ -31,7 +30,6 @@
from services.openai.chat import write_pr_body
from services.openai.agent import run_assistant
from services.supabase import SupabaseManager
from utils.file_manager import extract_file_name
from utils.text_copy import pull_request_completed, request_limit_reached

supabase_manager = SupabaseManager(url=SUPABASE_URL, key=SUPABASE_SERVICE_ROLE_KEY)
Expand Down Expand Up @@ -163,25 +161,7 @@ async def handle_gitauto(payload: GitHubLabeledPayload, trigger_type: str) -> No
f"{time.strftime('%H:%M:%S', time.localtime())} Remote branch created: {new_branch}.\n"
)

token_input, token_output, diffs = run_assistant(
file_paths=file_paths,
issue_title=issue_title,
issue_body=issue_body,
issue_comments=issue_comments,
owner=owner,
pr_body=pr_body,
ref=base_branch,
repo=repo_name,
token=token,
)

update_comment(
comment_url=comment_url,
token=token,
body="![X](https://progress-bar.dev/50/?title=Progress&width=800)\nHalf way there!",
)

run_assistant(
token_input, token_output = run_assistant(
file_paths=file_paths,
issue_title=issue_title,
issue_body=issue_body,
Expand Down
4 changes: 2 additions & 2 deletions services/openai/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def run_assistant(
comment_url: str,
token: str,
new_branch: str,
) -> tuple[int, int, list[str]]:
) -> tuple[int, int]:
# Create a message in the thread
data: dict[str, str | list[str]] = {
"owner": owner,
Expand Down Expand Up @@ -183,7 +183,7 @@ def run_assistant(
token_input = int(len(input_data) / 4)
token_output = int(len(output_data) / 4)

return token_input, token_output, output
return token_input, token_output


def submit_message(
Expand Down
2 changes: 1 addition & 1 deletion services/openai/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def why_modifying_diffs(why: str, *args: str, **kwargs: str) -> None:

COMMIT_MULTIPLE_CHANGES_TO_REMOTE_BRANCH: shared_params.FunctionDefinition = {
"name": "commit_multiple_changes_to_remote_branch",
"description": "Commits diffs to GitHub remote branch given the diffs, new_branch, owner, repo, and token",
"description": "Commits diffs to GitHub remote branch. Inputs are the array diffs, new_branch, owner, repo, and token",
"parameters": {
"type": "object",
"properties": {
Expand Down
2 changes: 1 addition & 1 deletion services/openai/instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
Please review the diffs you created from your previous response.
Ensure that you have followed the steps and instructions outlined in pr_body that was pass in the first message of this thread.
If everything is correct, please commit the changes.
If there are any issues, please use why_modifying_diffs function to explain why you're modifying it, then fix the diffs and commit the changes using commit_multiple_changes_to_remote_branch function.
If there are any issues, please use why_modifying_diffs function to explain why you're modifying it, then fix the diff. Lastly, commit the changes using commit_multiple_changes_to_remote_branch function.
"""

SYSTEM_INSTRUCTION_FOR_WRITING_PR = '''
Expand Down

0 comments on commit b7cd82e

Please sign in to comment.