Update claude-review.yml

This commit is contained in:
pacnpal
2024-12-10 15:27:35 -05:00
committed by GitHub
parent 0168e32da6
commit dbad4cf822

View File

@@ -91,22 +91,44 @@ jobs:
echo "Found $DIFF_SIZE bytes of relevant changes"
echo "diff_size=$DIFF_SIZE" >> $GITHUB_OUTPUT
# Prepare the diff content for the API request
DIFF_CONTENT=$(cat diff_filtered.txt)
# Prepare prompt and diff content
PROMPT="You are performing a code review. Please analyze this code diff and provide a thorough review that covers:
1. Potential conflicts with existing codebase
2. Code correctness and potential bugs
3. Security vulnerabilities or risks
4. Performance implications
5. Maintainability and readability issues
6. Adherence to best practices and coding standards
7. Suggestions for improvements
For each issue found:
- Explain the problem clearly
- Rate the severity (Critical/High/Medium/Low)
- Provide specific recommendations for fixes
- Include code examples where helpful
If no issues are found in a particular area, explicitly state that.
Here is the code diff to review:
\`\`\`
$(cat diff_filtered.txt)
\`\`\`"
# Create the API request using a heredoc
REQUEST=$(cat << EOF
{
"model": "claude-3-sonnet-20240229",
"max_tokens": 4096,
"temperature": 0.7,
"messages": [{
"role": "user",
"content": "You are performing a code review. Please analyze this code diff and provide a thorough review that covers:\n\n1. Potential conflicts with existing codebase\n2. Code correctness and potential bugs\n3. Security vulnerabilities or risks\n4. Performance implications\n5. Maintainability and readability issues\n6. Adherence to best practices and coding standards\n7. Suggestions for improvements\n\nFor each issue found:\n- Explain the problem clearly\n- Rate the severity (Critical/High/Medium/Low)\n- Provide specific recommendations for fixes\n- Include code examples where helpful\n\nIf no issues are found in a particular area, explicitly state that.\n\nHere is the code diff to review:\n\n\`\`\`\n$DIFF_CONTENT\n\`\`\`"
}]
}
EOF
)
# Create the API request using jq to properly escape the content
echo "Creating API request..."
REQUEST=$(jq -n \
--arg prompt "$PROMPT" \
'{
"model": "claude-3-sonnet-20240229",
"max_tokens": 4096,
"temperature": 0.7,
"messages": [{
"role": "user",
"content": $prompt
}]
}')
# Make the API request
echo "Sending request to Claude API..."
@@ -124,6 +146,7 @@ jobs:
echo 'EOF' >> $GITHUB_OUTPUT
else
echo "Error in Claude API response: $RESPONSE"
echo "Request was: $REQUEST"
exit 1
fi