Skip to content
Open
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
3 changes: 3 additions & 0 deletions .github/workflows/initiative-auto-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@ jobs:
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ISSUE_BODY: ${{ github.event.issue.body }}
ISSUE_TITLE: ${{ github.event.issue.title }}
with:
timeout_minutes: 5
max_attempts: 3
command: python $GITHUB_WORKSPACE/scripts/gptGenerateJsonFromIssue.py

- name: Generate PR
uses: actions/github-script@v6
env:
ISSUE_AUTHOR: ${{ github.event.issue.user.name }}
with:
script: |
const script = require(process.env.GITHUB_WORKSPACE + '/scripts/generatePullRequestForNewInitiative.js')
Expand Down
25 changes: 25 additions & 0 deletions _data/links/Children/Main/links.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,31 @@
"description": "קוד: בריינפופ23",
"url": "https://il.brainpop.com/",
"website": "https://il.brainpop.com/"
},
{
"displayName": "החמ'ל המתוק",
"name": "Bar213111",
"shortDescription": "FooBaz",
"description": "hello world",
"initiativeValidationDetails": "This initiative has been validated by the admin team",
"url": "Not Available",
"website": "Not Available",
"whatsapp": "Not Available",
"telegram": "Not Available",
"drive": "Not Available",
"form": "Not Available",
"docs": "Not Available",
"discord": "Not Available",
"facebook": "Not Available",
"instagram": "Not Available",
"tiktok": "Not Available",
"twitter": "Not Available",
"initiativeImage": "Not Available",
"tags": [
"החמ'ל",
"מתוק",
"ילדים"
]
}
]
}
185 changes: 185 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"remark-html": "^16.0.1"
},
"devDependencies": {
"@octokit/rest": "^20.0.2",
"@trivago/prettier-plugin-sort-imports": "^4.2.1",
"@types/lunr": "^2.3.6",
"@types/mixpanel-browser": "^2.47.4",
Expand Down
7 changes: 5 additions & 2 deletions scripts/generatePullRequestForNewInitiative.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = async ({github, context}) => {
}

const newResponse = await github.rest.pulls.create({
title: 'New Initiative: ' + name,
title: `New Initiative: ${name} [Suggested by ${ISSUE_AUTHOR}]`,
owner: context.repo.owner,
repo: context.repo.repo,
head: branch,
Expand Down Expand Up @@ -120,7 +120,10 @@ module.exports = async ({github, context}) => {

const PropValueUpper = value.toLocaleUpperCase("en-us");
if (upperCategoryJsonString.indexOf(PropValueUpper) !== -1) {
return await warnAndComment(`Initiative might already exist under this category, the value of property ${prop} is already present in the JSON: ${value}`, "suspected existing initiative", humanReadableJson);
return await warnAndComment(
`Initiative might already exist under this category, the value of property "${prop}" is already present in the JSON: "${value}". If you are certain this initiative doesn't exist`,
"suspected existing initiative",
humanReadableJson);
}
}

Expand Down
13 changes: 12 additions & 1 deletion scripts/gptGenerateJsonFromIssue.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,19 @@ def ask_gpt_for_initiative_json(self, issue_body: str) -> str:
logging.warn("GPT did not infer function calling, best-effort answer parsing will be performed")
return response_message["content"]

def get_new_initiative_details() -> str:
initiative_details = f"""
### Initiative Display Name
{os.environ["ISSUE_TITLE"].replace("[NEW-INITIATIVE]:", "")}

{os.environ["ISSUE_BODY"]}
"""

# replace double-quotes with single quotes to minimize chance of invalid JSON returned by GPT
return initiative_details.replace('"', "'")

if __name__ == "__main__":
gpt_response = GPTAssistant().ask_gpt_for_initiative_json(os.environ["ISSUE_BODY"])
gpt_response = GPTAssistant().ask_gpt_for_initiative_json(get_new_initiative_details())

respose_output_file = os.getenv("TEMP", "/tmp") + "/gpt-auto-comment.output"
logging.info(f"Writing GPT Response to {respose_output_file}:\n{gpt_response}")
Expand Down