Skip to content

Commit

Permalink
Update OpenAI prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
arkid15r committed Sep 14, 2024
1 parent ab6fe24 commit 619d8f3
Show file tree
Hide file tree
Showing 2 changed files with 10,251 additions and 3,095 deletions.
55 changes: 34 additions & 21 deletions backend/apps/github/management/commands/github_enrich_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,24 @@


class Command(BaseCommand):
help = "Populated GitHub issue summary."
help = "Enriches GitHub issue with AI generated data."

def add_arguments(self, parser):
parser.add_argument("--offset", default=0, required=False, type=int)
parser.add_argument("--update-hint", default=True, required=False, type=bool)
parser.add_argument("--update-summary", default=True, required=False, type=bool)

def handle(self, *args, **options):
open_ai = OpenAi()
open_issues = Issue.open_issues.without_summary.order_by("-created_at")
open_issues_count = open_issues.count()

update_hint = options["update_hint"]
update_summary = options["update_summary"]
update_fields = []
update_fields += ["hint"] if update_hint else []
update_fields += ["summary"] if update_summary else []

issues = []
offset = options["offset"]
for idx, issue in enumerate(open_issues[offset:]):
Expand All @@ -30,30 +38,35 @@ def handle(self, *args, **options):
open_ai.set_input(f"{issue.title}\r\n{issue.body}")

# Generate summary
open_ai.set_max_tokens(500).set_prompt(
(
"Summarize the following GitHub issue using imperative mood."
"Use a good amount technical details."
"Avoid using lists for description."
"Do not use mardown in output."
)
if issue.project.is_code_type or issue.project.is_tool_type
else (
"Summarize the following GitHub issue."
"Avoid mentioning author's name or issue creation date."
"Avoid using lists for description."
"Do not use markdown in output."
if update_summary:
open_ai.set_max_tokens(500).set_prompt(
(
"Summarize the following GitHub issue."
"Avoid mentioning author's name or issue creation date."
"Avoid using lists for description."
"Do not use markdown in output."
"Limit summary by 3 sentences."
)
if issue.project.is_documentation_type
else (
"Summarize the following GitHub issue using imperative mood."
"Use a good amount technical details."
"Avoid using lists for description."
"Do not use mardown in output."
"Limit summary by 3 sentences."
)
)
)
issue.summary = open_ai.complete() or ""
issue.summary = open_ai.complete() or ""

# Generate hint
open_ai.set_max_tokens(1000).set_prompt(
"Describe possible first steps of approaching the problem."
)
issue.hint = open_ai.complete() or ""
if update_hint:
open_ai.set_max_tokens(1000).set_prompt(
"Describe possible steps of approaching the problem."
"Limit output by 10 steps."
)
issue.hint = open_ai.complete() or ""

issues.append(issue)

# Bulk save data.
Issue.bulk_save(issues, fields=("hint", "summary"))
Issue.bulk_save(issues, fields=update_fields)
Loading

0 comments on commit 619d8f3

Please sign in to comment.