-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/ERNI-Academy/asset-promptin…
- Loading branch information
Showing
2 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
name: 📖 Prompt for AIDA Marketplace | ||
description: Template for generating a prompt in the AIDA Marketplace. | ||
title: Add here the title of the prompt | ||
labels: [prompt] | ||
assignees: [] | ||
|
||
body: | ||
- type: input | ||
id: author | ||
attributes: | ||
label: Author | ||
description: Enter your name. | ||
placeholder: "John Doe" | ||
validations: | ||
required: true | ||
|
||
- type: input | ||
id: tags | ||
attributes: | ||
label: Tags | ||
description: Provide relevant tags (comma-separated). | ||
placeholder: "diversity, text, enhancer" | ||
validations: | ||
required: true | ||
|
||
- type: textarea | ||
id: prompt | ||
attributes: | ||
label: Prompt | ||
description: The raw prompt text. | ||
placeholder: | | ||
Given a text, enhance it to be more inclusive and diverse. | ||
- Do not use offensive words or phrases. | ||
- Do not use words or phrases that are not inclusive or diverse. | ||
- Do it in a way that it sounds natural and not forced. | ||
Text to enhance: | ||
\`\`\` | ||
[TEXT] | ||
\`\`\` | ||
render: yaml | ||
validations: | ||
required: true | ||
|
||
- type: markdown | ||
attributes: | ||
value: | | ||
--- | ||
title: "{{ ISSUE_TITLE }}" | ||
author: "{{ author }}" | ||
tags: [{{ tags }}] | ||
--- | ||
{{ prompt }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
name: Issue to PR Automation | ||
|
||
on: | ||
issues: | ||
types: [opened] | ||
|
||
jobs: | ||
create_pr: | ||
if: contains(toJson(github.event.issue.labels), '"prompt"') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Git Config | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
- name: Extract Issue Data | ||
id: extract_data | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const issueBody = context.payload.issue.body; | ||
const issueTitle = context.payload.issue.title; | ||
const lines = issueBody.split('\n'); | ||
function extractSection(header) { | ||
const sectionLines = []; | ||
let inSection = false; | ||
for (const line of lines) { | ||
if (line.trim().toLowerCase() === `### ${header.toLowerCase()}`) { | ||
inSection = true; | ||
continue; | ||
} | ||
if (inSection && line.startsWith('### ')) { | ||
break; | ||
} | ||
if (inSection) { | ||
sectionLines.push(line); | ||
} | ||
} | ||
return sectionLines.join('\n').trim(); | ||
} | ||
const author = extractSection('Author'); | ||
const tags = extractSection('Tags'); | ||
const promptContent = extractSection('Prompt'); | ||
// Base64 encode the prompt content | ||
const promptContentB64 = Buffer.from(promptContent, 'utf-8').toString('base64'); | ||
// Set outputs | ||
core.setOutput('PROMPT_NAME', issueTitle); | ||
core.setOutput('AUTHOR', author); | ||
core.setOutput('TAGS', tags); | ||
core.setOutput('PROMPT_CONTENT_B64', promptContentB64); | ||
- name: Debug Extracted Data | ||
run: | | ||
echo "Prompt Name: ${{ steps.extract_data.outputs.PROMPT_NAME }}" | ||
echo "Author: ${{ steps.extract_data.outputs.AUTHOR }}" | ||
echo "Tags: ${{ steps.extract_data.outputs.TAGS }}" | ||
echo "Prompt Content:" | ||
echo "${{ steps.extract_data.outputs.PROMPT_CONTENT_B64 }}" | base64 --decode | ||
# Remove 'Create Branch' and 'Push Branch' steps | ||
|
||
- name: Create File from Issue | ||
run: | | ||
# Retrieve variables | ||
PROMPT_NAME="${{ steps.extract_data.outputs.PROMPT_NAME }}" | ||
AUTHOR="${{ steps.extract_data.outputs.AUTHOR }}" | ||
TAGS="${{ steps.extract_data.outputs.TAGS }}" | ||
PROMPT_CONTENT_B64="${{ steps.extract_data.outputs.PROMPT_CONTENT_B64 }}" | ||
# Decode the base64 content | ||
PROMPT_CONTENT=$(echo "$PROMPT_CONTENT_B64" | base64 --decode) | ||
# Sanitize prompt name to create a valid file name | ||
FILE_NAME="$(echo "$PROMPT_NAME" | tr '[:upper:]' '[:lower:]' \ | ||
| sed -E 's/[^a-z0-9]+/-/g; s/^-+|-+$//g')" | ||
FILE_PATH="aida-prompts/_prompts/${FILE_NAME}.md" | ||
echo "Creating file at $FILE_PATH" | ||
mkdir -p "$(dirname "$FILE_PATH")" | ||
# Write the content to the .md file using cat | ||
{ | ||
echo '---' | ||
echo "title: \"$PROMPT_NAME\"" | ||
echo "author: \"$AUTHOR\"" | ||
echo "tags: [${TAGS}]" | ||
echo '---' | ||
echo | ||
echo "$PROMPT_CONTENT" | ||
} > "$FILE_PATH" | ||
# Do not commit changes here | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
commit-message: "Add prompt '${{ steps.extract_data.outputs.PROMPT_NAME }}' from Issue #${{ github.event.issue.number }}" | ||
committer: 'GitHub <[email protected]>' | ||
author: 'Your Name <[email protected]>' # Replace with your name and email | ||
title: "Add Prompt: ${{ steps.extract_data.outputs.PROMPT_NAME }}" | ||
body: | | ||
Adds a new prompt from Issue #${{ github.event.issue.number }}. | ||
Automatically generated by GitHub Actions. | ||
branch: "issue-${{ github.event.issue.number }}" | ||
base: main | ||
delete-branch: false | ||
overwrite-existing: true |