The ability to use pr-agent on Azure Devops using azure open ai #1654
vino-architect
started this conversation in
General
Replies: 1 comment
-
thoroughly review i dont see you gave all the needed keys. and if this doesn't work, make sure, with plain litellm, you are able to access your model. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to use PR Agent for my python code review using Azure Open AI.
I am not finding the right document for it. On below yaml, I am getting error as "2025-03-27 08:03:10.452 | WARNING | pr_agent.algo.ai_handlers.litellm_ai_handler:chat_completion:319 - Error during LLM inference: litellm.AuthenticationError: AuthenticationError: OpenAIException - Error code: 401 - {'error': {'message': 'Incorrect API key provided: c9690741********************6f09. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}"
trigger: none
pr:
branches:
include:
- 'explore/test-ai-code-review-appraise'
autoCancel: true
drafts: false
stages:
displayName: 'PR Agent Stage'
jobs:
displayName: 'PR Agent Job'
pool:
vmImage: 'ubuntu-latest'
container:
image: codiumai/pr-agent:latest
options: --entrypoint ""
variables:
group: pr_agent # Reference the variable group
steps:
script: |
echo "Running PR Agent action step"
Print environment variables for debugging
echo "SYSTEM_COLLECTIONURI=${SYSTEM_COLLECTIONURI}"
echo "SYSTEM_TEAMPROJECT=${SYSTEM_TEAMPROJECT}"
echo "BUILD_REPOSITORY_NAME=${BUILD_REPOSITORY_NAME}"
echo "SYSTEM_PULLREQUEST_PULLREQUESTID=${SYSTEM_PULLREQUEST_PULLREQUESTID}"
echo "API Key: ${openai_api_key}" # Print API key for debugging
echo "API Key Source: ${api_key_source}"
Check if SYSTEM_PULLREQUEST_PULLREQUESTID is empty
if [ -z "${SYSTEM_PULLREQUEST_PULLREQUESTID}" ]; then
echo "Error: SYSTEM_PULLREQUEST_PULLREQUESTID is not set."
exit 1
fi
Construct PR_URL
PR_URL="${SYSTEM_COLLECTIONURI}${SYSTEM_TEAMPROJECT}/_git/${BUILD_REPOSITORY_NAME}/pullrequest/${SYSTEM_PULLREQUEST_PULLREQUESTID}"
echo "PR_URL=$PR_URL"
Extract organization URL from System.CollectionUri
ORG_URL=$(echo "${SYSTEM_COLLECTIONURI}" | sed 's//$//') # Remove trailing slash if present
echo "Organization URL: $ORG_URL"
export azure_devops__org="$ORG_URL"
export config__git_provider="azure"
Verify the endpoint and API key
echo "Using OpenAI endpoint: $openai__endpoint"
echo "Using OpenAI API key: $openai_api_key"
echo "Using Azure OpenAI Endpoint: $azureopenai_endpoint"
Run PR Agent commands with additional debugging
pr-agent --pr_url="$PR_URL" describe || { echo "Describe command failed"; exit 1; }
pr-agent --pr_url="$PR_URL" review || { echo "Review command failed"; exit 1; }
pr-agent --pr_url="$PR_URL" improve || { echo "Improve command failed"; exit 1; }
Run AI Code Review
python -m pip install requests
python code_review.py
env:
azure_devops__pat: $(azure_devops_pat)
openai_api_key: $(openai_api_key) # Use the variable from the variable group
api_key_source: $(openai_key_source)
openai__endpoint: $(azureopenai_endpoint)
displayName: 'Run PR Agent and AI Code Review'
Beta Was this translation helpful? Give feedback.
All reactions