From c66fc8c3f370dbd513e926e597b8ca6b3d24838f Mon Sep 17 00:00:00 2001 From: Antoine Barthelemy Date: Sat, 20 May 2023 16:49:28 +0200 Subject: [PATCH 1/3] init(pr): add file for test --- short_commit_sha | 1 + 1 file changed, 1 insertion(+) create mode 100644 short_commit_sha diff --git a/short_commit_sha b/short_commit_sha new file mode 100644 index 0000000..713337f --- /dev/null +++ b/short_commit_sha @@ -0,0 +1 @@ +305a1a4 From 13a42e7a820fa9908e815bed8e511fa226d6bfb0 Mon Sep 17 00:00:00 2001 From: Antoine Barthelemy Date: Sat, 20 May 2023 16:57:44 +0200 Subject: [PATCH 2/3] test --- dev.sh | 2 +- src/GitHub/pullrequest.py | 10 ++-------- src/OpenAI/model.py | 2 +- src/main.py | 8 ++++---- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/dev.sh b/dev.sh index d721dce..6d86eaf 100755 --- a/dev.sh +++ b/dev.sh @@ -15,7 +15,7 @@ git push --set-upstream origin "$BRANCH" gh pr create --title "[TEST] - PR $ID" --body "" -python src/main.py +#python src/main.py #gh pr view # #git checkout main diff --git a/src/GitHub/pullrequest.py b/src/GitHub/pullrequest.py index 26d9d2b..9f00ee6 100644 --- a/src/GitHub/pullrequest.py +++ b/src/GitHub/pullrequest.py @@ -52,11 +52,5 @@ def diff(self): response = requests.get(diff_url) return response.text - -# def change_pull_request_description(pr_number, new_description): -# g = Github() -# owner, repo = get_owner_and_repo() -# repository = g.get_repo(f'{owner}/{repo}') -# -# pull_request = repository.get_pull(pr_number) -# pull_request.edit(body=new_description) + def update_description(self, new_description): + self.__pulls.edit(body=new_description) diff --git a/src/OpenAI/model.py b/src/OpenAI/model.py index 39624d1..122c47e 100644 --- a/src/OpenAI/model.py +++ b/src/OpenAI/model.py @@ -34,7 +34,7 @@ def _template(template, template_file_path): return " " # should exit fail def generate_description(self, text): - data = self.__header + self.__template + "\n\n\n" + text + data = self.__header + self.__template + "\n\n" + text openai.api_key = self.__key response = openai.Completion.create( model=self.__model, diff --git a/src/main.py b/src/main.py index 2b9c96f..2b2af33 100755 --- a/src/main.py +++ b/src/main.py @@ -37,10 +37,10 @@ def main(): logging.debug(ai) description = ai.generate_description(patch) -# #print(f"text={description}") -# print(pr.number) -# description="hey!" -# gh.change_pull_request_description(pr.number, description) + logging.debug(description) + outputs.set_action_outputs({"text": f"{description}"}) + + pullrequest.update_description(description) if __name__ == '__main__': From 13ce60514ad5a046c14b73c8d807597fad74133a Mon Sep 17 00:00:00 2001 From: Antoine Barthelemy Date: Sat, 20 May 2023 17:21:03 +0200 Subject: [PATCH 3/3] need to fix debug --- src/GitHub/outputs.py | 1 + src/GitHub/pullrequest.py | 1 + src/OpenAI/model.py | 1 + src/main.py | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/GitHub/outputs.py b/src/GitHub/outputs.py index 004ea85..8b580d5 100644 --- a/src/GitHub/outputs.py +++ b/src/GitHub/outputs.py @@ -1,4 +1,5 @@ import os +import logging def set_action_outputs(output_pairs): diff --git a/src/GitHub/pullrequest.py b/src/GitHub/pullrequest.py index 9f00ee6..c3b348d 100644 --- a/src/GitHub/pullrequest.py +++ b/src/GitHub/pullrequest.py @@ -1,5 +1,6 @@ import requests import subprocess +import logging from github import Github diff --git a/src/OpenAI/model.py b/src/OpenAI/model.py index 122c47e..98b5d63 100644 --- a/src/OpenAI/model.py +++ b/src/OpenAI/model.py @@ -1,6 +1,7 @@ import os import sys import openai +import logging class AiRequest: diff --git a/src/main.py b/src/main.py index 2b2af33..f2c9808 100755 --- a/src/main.py +++ b/src/main.py @@ -3,9 +3,9 @@ This module generates a pull request description using the OpenAI GPT-3.5 language model. """ -import logging import os import sys +import logging import configuration.logs as logs import configuration.parse as parse