Skip to content

Document how to extract the logfiles from the backups #120

Document how to extract the logfiles from the backups

Document how to extract the logfiles from the backups #120

name: Claude Assistant
on:
issue_comment:
types: [created, edited]
jobs:
claude_assist_comment:
if: contains(github.event.comment.body, 'claude')
runs-on: ubuntu-latest
steps:
- name: Get issue details and comments
id: get-issue-details
run: |
echo issue-details=$(
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${{github.repository}}/issues/${{github.event.issue.number}}" | \
jq '. | {title, body, username: .user.login, created_at, updated_at}'
) >> $GITHUB_OUTPUT
echo issue-comments=$(
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${{github.repository}}/issues/${{github.event.issue.number}}/comments" | \
jq '[.[]? | {id, body, username: .user.login, created_at, updated_at}]' | \
jq '.[0:-1]'
) >> $GITHUB_OUTPUT
- name: Generate message to send to Claude
id: generate-message
env:
MESSAGE_CONTENT: |
You are the AI assistant, "Claude", providing support on the PyMedPhys GitHub issue tracker.
Please be helpful and supportive. Please respond directly to the calling comment while using
the GitHub issue details and corresponding GitHub issue comment history (non-inclusive of the
latest, calling comment) below.
<github-issue-details>
${{ steps.get-issue-details.outputs.issue-details }}
</github-issue-details>
<github-issue-comments>
${{ steps.get-issue-details.outputs.issue-comments }}
</github-issue-comments>
<calling-comment>
${{ github.event.comment.body }}
</calling-comment>
run: |
EOF=$(openssl rand -hex 16)
echo "message-content<<$EOF" >> $GITHUB_OUTPUT
echo "$MESSAGE_CONTENT" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
- name: Get Claude's response
id: claude-response
env:
MESSAGE_CONTENT: "${{ steps.generate-message.outputs.message-content }}"
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
MESSAGES_JSON=$(
jq -n \
--arg role "user" \
--arg content "$MESSAGE_CONTENT" \
'$ARGS.named'
)
MAX_TOKENS=1024
DATA_JSON=$(
jq -nr \
--arg model "claude-3-opus-20240229" \
--argjson max_tokens "$MAX_TOKENS" \
--argjson messages "[$MESSAGES_JSON]" \
'$ARGS.named'
)
echo response=$(
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d "$DATA_JSON"
) >> $GITHUB_OUTPUT
- name: Get URL to prompt log
uses: Tiryoh/gha-jobid-action@v1
id: job-info
with:
job_name: "${{ github.job }}"
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create issue comment with Claude's error
uses: peter-evans/create-or-update-comment@v4
if: ${{ fromJson(steps.claude-response.outputs.response).error != '' }}
with:
issue-number: ${{ github.event.issue.number }}
body: |
**AI Assistant Claude**
ERROR
*Prompt sent to Claude:* [link](${{ steps.job-info.outputs.html_url }}#step:3:8)
*Comment that called Claude:*
> ${{ github.event.comment.body }}
*Claude's error message:*
${{ fromJson(steps.claude-response.outputs.response).error.message }}
- name: Create issue comment with Claude's response
uses: peter-evans/create-or-update-comment@v4
if: ${{ fromJson(steps.claude-response.outputs.response).error == '' }}
with:
issue-number: ${{ github.event.issue.number }}
body: |
**AI Assistant Claude**
*Prompt sent to Claude:* [link](${{ steps.job-info.outputs.html_url }}#step:3:8)
*Comment that called Claude:*
> ${{ github.event.comment.body }}
*Claude's response:*
${{ fromJson(steps.claude-response.outputs.response).content[0].text }}