Codium-ai / pr-agent

🚀CodiumAI PR-Agent: An AI-Powered 🤖 Tool for Automated Pull Request Analysis, Feedback, Suggestions and More! 💻🔍
Apache License 2.0
5.68k stars 525 forks source link

Clarifications on Azure Open AI configuration #879

Open krishnakalyan3 opened 5 months ago

krishnakalyan3 commented 5 months ago

I am unable to get the PR agent to work. Can you please let me know if I have configured the action correctly.

on:
  pull_request:
    types: [opened, reopened, ready_for_review]
  issue_comment:
jobs:
  pr_agent_job:
    if: ${{ github.event.sender.type != 'Bot' }}
    runs-on: ubuntu-latest
    permissions:
      issues: write
      pull-requests: write
      contents: write
    name: Run pr agent on every pull request, respond to user comments
    steps:
      - name: PR Agent action step
        id: pragent
        uses: Codium-ai/pr-agent@main
        env:
          OPENAI.API_TYPE: "azure"
          OPENAI.DEPLOYMENT_ID: "gpt4" 
          OPENAI_KEY: xxx
          OPENAI.API_BASE: xxx
          OPENAI.API_VERSION: "2024-02-15-preview"
          OPENAI.GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Related: https://github.com/Codium-ai/pr-agent/issues/245

krishnakalyan3 commented 5 months ago

cc: @okotek

gregmeldrum commented 4 months ago

As a workaround, I added the following to my .pr_agent.toml and it worked:

[openai]
api_type = "azure"
api_version = '2024-02-01'
api_base = ...
deployment_id = "gpt-4"
blakeashleyjr commented 4 months ago

@gregmeldrum Do you mind providing more details about your config? I can't get mine working with Azure AI. Did you change the action before it started working?

gregmeldrum commented 3 months ago

@blakeashleyjr I realize that one of the key things I did (happy accident) was to name my azure model deployments the same as what you would expect for openai model names (for instance "gpt-4" and "gpt-4o"). I set the OPENAI_KEY to be my Azure OpenAI key. The main part of the work-around however was what I mentioned above about adding an [openai] section in my .pr_agent.toml in the root directory of the repo with the appropriate azure settings.

[openai]
api_type = "azure"
api_version = '2024-02-01'
api_base = ....
deployment_id = "gpt-4"

[config]
model="gpt-4o"
model_turbo="gpt-4"
Jyny commented 3 months ago

@krishnakalyan3 this works for me:

env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    github_action_config.auto_review: "true"
    github_action_config.auto_describe: "true"
    github_action_config.auto_improve: "true"
    OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
    OPENAI.API_TYPE: 'azure'
    OPENAI.API_BASE: 'https://YOUR_RESOURCE.openai.azure.com'
    OPENAI.DEPLOYMENT_ID: 'YOUR_DEPLOYMENT'
    OPENAI.API_VERSION: '2024-02-01'