Codium-ai / pr-agent

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

Unable to get PR-Agent GitHub Action to use Azure OpenAI #364

Closed JyrkiHei closed 1 year ago

JyrkiHei commented 1 year ago

Hi! Asked this on discord also, but was redirected here. Tried to find a solution, but did not find anything matching. I'm trying to setup the GitHub Action version of PR-Agent to give review or description on our GitHub PR changes. We want to use our own instance of Azure OpenAi Service instead of the "public" OpenAi service. Deployment_ID is the name of the deployed model in Azure OpenAI Service and the model is 'gpt-35-turbo'.lso I want to use Azure OpenAI Service, but I seem to get this error all the time*openai.error.AuthenticationError: Incorrect API key provided:**.

I cannot use GPT4 right now, the 'gpt-latest' deployment is gpt-35-turbo -model.

When I run the github action with these environment variables (key and github token naturally masked, tried also adding that config.model) I get this error saying that the OpenAI key is wrong and shows URL where I can get those API keys. But I want to use our own Azure OpenAI instance instead.... I'm really confused what environment variables should I set to get this working 😦

image

And I don't have any .secrets.toml or configuration.toml files in my repository... Not sure if I should have or not if I'm using these env variables.

Only results I get from running this GitHub action is ~400 lines of python error logging and in the error it says couple of times 'openai.error.AuthenticationError: Incorrect API key provided: **. You can find your API key at https://platform.openai.com/account/api-keys.'

Any ideas? (I was requested to tag you @krrishdholakia, if you could help)

mrT23 commented 1 year ago

@krrishdholakia does litellm support this kind of deployment? it does seem to follow: https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#azure

krrishdholakia commented 1 year ago

Hey @JyrkiHei @mrT23 if i understand this - are you asking if litellm lets you set your azure deployment id as an environment variable?

isn't this already being read from the environment and passed here?

Screenshot 2023-10-09 at 8 07 11 AM
mrT23 commented 1 year ago

@JyrkiHei can you try debugging it from CLI ? i suspect there might be some naming issue

pr_agent/algo/pr_processing.py, line 240

def _get_all_deployments(all_models: List[str]) -> List[str]:
    deployment_id = get_settings().get("openai.deployment_id", None)

so maybe the var name should be 'openai.deployment_id'

I suggest catching a breaking there, and making sure you are able to pass the deployment_id

JyrkiHei commented 1 year ago

I think that was it @mrT23! Thank you!

I changed my configuration to this (not sure yet if all values are needed, because I was just testing around):

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_KEY: ${{ secrets.AZURE_OPENAI_KEY }}
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      OPENAI_API_TYPE: 'azure'
      OPENAI_API_VERSION: '2023-07-01-preview'
      OPENAI_API_BASE: 'https://genai-xxxx-xxxx.openai.azure.com'
      OPENAI.DEPLOYMENT_ID: 'gpt-latest'
      OPENAI.CONFIG_MODEL: 'gpt-35-turbo'
mrT23 commented 1 year ago

great 💯

will update the docs

hussam789 commented 1 year ago

Similar Issues


  1. [Feature request] Azure API not well supported / documented (score=0.90)

  2. Unrecognized request argument supplied: azure on GitHub Actions (score=0.89)

  3. Unable to use Github Action anymore (score=0.89)

  4. Not getting codium commands for PR agent on bitbucket (score=0.86)

nandantws commented 1 year ago

Similar Issues


  1. [Feature request] Azure API not well supported / documented (score=0.90)

  2. Unrecognized request argument supplied: azure on GitHub Actions (score=0.89)

  3. Unable to use Github Action anymore (score=0.89)

  4. Issue on github action (score=0.86)