Skip to content

Commit

Permalink
ci(bot): added model and anthropic_api_key inputs, use ~/.config/gptm…
Browse files Browse the repository at this point in the history
…e/config.toml file passed to Docker for api keys and setting model
  • Loading branch information
ErikBjare committed Sep 5, 2024
1 parent b8a5822 commit 8a7fb5c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
32 changes: 27 additions & 5 deletions .github/actions/bot/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ description: 'A composite action for the gptme-bot workflow'
inputs:
openai_api_key:
description: 'OpenAI API Key'
required: true
required: false
anthropic_api_key:
description: 'Anthropic API Key'
required: false
model:
description: 'Model to use'
required: false
github_token:
description: 'GitHub Token'
required: true
Expand Down Expand Up @@ -93,16 +99,31 @@ runs:
fi
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- name: Write gptme config.toml
shell: bash
run: |
mkdir -p ~/.config/gptme
cat > ~/.config/gptme/config.toml << EOF
[prompt]
about_user = "I am a bot executing commands from GitHub comments."
response_preference = "Don't explain basic concepts"
[env]
MODEL = "${{ inputs.model }}"
OPENAI_API_KEY = "${{ inputs.openai_api_key }}"
ANTHROPIC_API_KEY = "${{ inputs.anthropic_api_key }}"
EOF
- name: Determine action type
id: determine_action
if: steps.detect_command.outputs.gptme_command
shell: bash
env:
OPENAI_API_KEY: ${{ inputs.openai_api_key }}
GPTME_COMMAND: ${{ steps.detect_command.outputs.gptme_command }}
run: |
FULL_OUTPUT=$(docker run --rm \
-e OPENAI_API_KEY=$OPENAI_API_KEY \
-v ~/.config/gptme:/home/appuser/.config/gptme \
ghcr.io/erikbjare/gptme:latest \
--non-interactive \
"Determine if this command requires changes to be made or just a response. Respond with either 'make_changes' or 'respond'. Command: $GPTME_COMMAND")
Expand All @@ -126,6 +147,7 @@ runs:
GITHUB_TOKEN: ${{ inputs.github_token }}
GPTME_COMMAND: ${{ steps.detect_command.outputs.gptme_command }}
OPENAI_API_KEY: ${{ inputs.openai_api_key }}
ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key }}
run: |
gh issue view ${{ github.event.issue.number }} > issue.md
gh issue view ${{ github.event.issue.number }} -c > comments.md
Expand All @@ -135,9 +157,9 @@ runs:
# run gptme with the extracted command and save logs
timeout 120 docker run --rm \
-v ~/.config/gptme:/home/appuser/.config/gptme \
-v $(pwd):/workspace \
-w /workspace \
-e OPENAI_API_KEY=$OPENAI_API_KEY \
ghcr.io/erikbjare/gptme:latest \
--non-interactive \
"$GPTME_COMMAND" "Here is the context from the issue or pull request:" issue.md comments.md \
Expand Down Expand Up @@ -165,9 +187,9 @@ runs:
run: |
# generate commit message
docker run --rm \
-v ~/.config/gptme:/home/appuser/.config/gptme \
-v $(pwd):/workspace \
-w /workspace \
-e OPENAI_API_KEY=$OPENAI_API_KEY \
ghcr.io/erikbjare/gptme:latest \
--non-interactive \
"Run 'git diff --staged' to inspect what has changed." \
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
- name: Run gptme-bot action
uses: ./.github/actions/bot
with:
model: 'anthropic/claude-3-5-sonnet-20240620'
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
allowlist: "ErikBjare"

0 comments on commit 8a7fb5c

Please sign in to comment.