Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Azure OpenAI setup problems #4875

Merged
merged 21 commits into from Jul 7, 2023

Conversation

jayden5744
Copy link
Contributor

Background

Changes

Documentation

x

Test Plan

CI

PR Quality Checklist

  • My pull request is atomic and focuses on a single change.
  • I have thoroughly tested my changes with multiple different prompts.
  • I have considered potential risks and mitigations for my changes.
  • I have documented my changes clearly and comprehensively.
  • I have not snuck in any "extra" small tweaks changes.
  • I have run the following commands against my code to ensure it passes our linters:
    black .
    isort .
    mypy
    autoflake --remove-all-unused-imports --recursive --ignore-init-module-imports --ignore-pass-after-docstring autogpt tests --in-place

@netlify
Copy link

netlify bot commented Jul 3, 2023

Deploy Preview for auto-gpt-docs canceled.

Name Link
🔨 Latest commit 21a5ba7
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/64a75fd2e91b5f00085e5ebf

@github-actions github-actions bot added the size/m label Jul 3, 2023
@codecov
Copy link

codecov bot commented Jul 3, 2023

Codecov Report

Patch coverage: 64.70% and project coverage change: +0.16 🎉

Comparison is base (e4a337f) 50.05% compared to head (21a5ba7) 50.21%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4875      +/-   ##
==========================================
+ Coverage   50.05%   50.21%   +0.16%     
==========================================
  Files         116      116              
  Lines        4799     4809      +10     
  Branches      643      645       +2     
==========================================
+ Hits         2402     2415      +13     
+ Misses       2218     2215       -3     
  Partials      179      179              
Impacted Files Coverage Δ
autogpt/llm/utils/__init__.py 49.25% <0.00%> (-1.48%) ⬇️
autogpt/memory/vector/utils.py 78.12% <0.00%> (-5.21%) ⬇️
autogpt/config/config.py 83.89% <91.66%> (+4.75%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@lc0rp
Copy link
Contributor

lc0rp commented Jul 4, 2023

@jayden5744, thanks for the PR. Please write some tests!

@github-actions
Copy link

github-actions bot commented Jul 5, 2023

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

@github-actions github-actions bot added size/l and removed size/m labels Jul 6, 2023
@github-actions github-actions bot removed the conflicts Automatically applied to PRs with merge conflicts label Jul 6, 2023
@github-actions
Copy link

github-actions bot commented Jul 6, 2023

Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.

autogpt/config/config.py Outdated Show resolved Hide resolved
autogpt/config/config.py Outdated Show resolved Hide resolved
autogpt/config/config.py Outdated Show resolved Hide resolved
lc0rp and others added 5 commits July 6, 2023 15:58
- Refactor the `azure_config_file` attribute in the `Config` class to be optional.
- Refactor the `azure_model_to_deployment_id_map` attribute in the `Config` class to be optional and provide default values.
- Update the `get_azure_deployment_id_for_model` function to accept additional parameters.
- Update references to `get_azure_deployment_id_for_model` in `create_text_completion`, `create_chat_completion`, and `get_embedding` functions to pass the required parameters.
@collijk
Copy link
Contributor

collijk commented Jul 6, 2023

@jayden5744 Overall great work. I've added some changes to reduce code duplication and avoid setting global parameters.

@lc0rp lc0rp added this to the v0.4.4 Release milestone Jul 7, 2023
@collijk collijk merged commit ac17518 into Significant-Gravitas:master Jul 7, 2023
15 of 16 checks passed
Pwuts added a commit to Pwuts/Auto-GPT that referenced this pull request Jul 7, 2023
@jayden5744
Copy link
Contributor Author

@collijk
My existing code excludes the code below,

# autogpt/config/config.py
if config_dict["use_azure"]: # line 294 
      azure_config = cls.load_azure_config(config_dict["azure_config_file"])
      config_dict.update(azure_config)
     
     # Add the three lines of code below
      openai.api_type = azure_config["openai_api_type"]
      openai.api_base = azure_config["openai_api_base"]
      openai.api_version = azure_config["openai_api_version"]

which causes the error openai.error.AuthenticationError: Incorrect API key provided to occur when calling the openai api without changing to the azure settings.
I need to fix this again.

@collijk
Copy link
Contributor

collijk commented Jul 7, 2023

@jayden5744

We specifically don't want to do

     # Add the three lines of code below
      openai.api_type = azure_config["openai_api_type"]
      openai.api_base = azure_config["openai_api_base"]
      openai.api_version = azure_config["openai_api_version"]

as this reaches into module namespace and has global impacts. These should be passed as arguments to the API call (as they are now). I'm setting up some testing on azure tomorrow (we unfortunately don't have access as part of our CI) and will try to reproduce your issue.

@collijk collijk mentioned this pull request Jul 7, 2023
6 tasks
dayofthedave pushed a commit to dayofthedave/Auto-GPT that referenced this pull request Jul 17, 2023
* [Fix] Recover the azure config load function

* [Style] Apply black, isort, mypy, autoflake

* [Fix] Rename the return parameter from 'azure_model_map' to 'azure_model_to_deployment_id_map'

* [Feat] Change the azure config file path to be dynamically configurable

* [Test] Add azure_config and azure deployment_id_for_model

* [Style] Apply black, isort, mypy, autoflake

* [Style] Apply black, isort, mypy, autoflake

* Refactor Azure configuration

- Refactor the `azure_config_file` attribute in the `Config` class to be optional.
- Refactor the `azure_model_to_deployment_id_map` attribute in the `Config` class to be optional and provide default values.
- Update the `get_azure_deployment_id_for_model` function to accept additional parameters.
- Update references to `get_azure_deployment_id_for_model` in `create_text_completion`, `create_chat_completion`, and `get_embedding` functions to pass the required parameters.

* Clean up process for azure

* Docstring

* revert some unneccessary fiddling

* Avoid altering args to models

* Retry on 404s

* Don't permanently change the environment

* Formatting

---------

Co-authored-by: Luke <2609441+lc0rp@users.noreply.github.com>
Co-authored-by: lc0rp <2609411+lc0rp@users.noreply.github.com>
Co-authored-by: collijk <collijk@uw.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

5 participants