From ca50724952a3ec2ae63786ba5f5de28f3cdcebe0 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 5 Sep 2023 15:19:56 -0700 Subject: [PATCH 1/2] adding details on calling azure --- INSTALL.md | 9 +-------- Usage.md | 21 +++++++++++++++++++-- pr_agent/algo/ai_handler.py | 2 -- pr_agent/settings/configuration.toml | 1 - 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 285b3f14..cd856323 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -363,11 +363,4 @@ WEBHOOK_SECRET=$(python -c "import secrets; print(secrets.token_hex(10))") In the "Trigger" section, check the ‘comments’ and ‘merge request events’ boxes. 6. Test your installation by opening a merge request or commenting or a merge request using one of CodiumAI's commands. ---- - -### Appendix - **Debugging LLM API Calls** -If you're testing your codium/pr-agent server, and need to see if calls were made successfully + the exact call logs, you can use the [LiteLLM Debugger tool](https://docs.litellm.ai/docs/debugging/hosted_debugging). - -You can do this by setting `litellm_debugger=true` in configuration.toml. Your Logs will be viewable in real-time @ `admin.litellm.ai/`. Set your email in the `.secrets.toml` under 'user_email'. - - \ No newline at end of file +--- \ No newline at end of file diff --git a/Usage.md b/Usage.md index 336de974..9cf774e7 100644 --- a/Usage.md +++ b/Usage.md @@ -149,11 +149,28 @@ TBD #### Changing a model See [here](pr_agent/algo/__init__.py) for the list of available models. -To use Llama2 model, for example, set: +To use Azure, set: +``` +api_key = "" # your azure api key +api_type = "azure" +api_version = '2023-05-15' # Check Azure documentation for the current API version +api_base = "" # The base URL for your Azure OpenAI resource. e.g. "https://.openai.azure.com" +deployment_id = "" # The deployment name you chose when you deployed the engine +``` +in your .secrets.toml + +and ``` [config] +model="" # the OpenAI model you've deployed on Azure (e.g. gpt-3.5-turbo) +``` +in the configuration.toml + +To use Llama2 model with Replicate, for example, set: +``` +[config] # in configuration.toml model = "replicate/llama-2-70b-chat:2c1608e18606fad2812020dc541930f2d0495ce32eee50074220b87300bc16e1" -[replicate] +[replicate] # in .secrets.toml key = ... ``` (you can obtain a Llama2 key from [here](https://replicate.com/replicate/llama-2-70b-chat/api)) diff --git a/pr_agent/algo/ai_handler.py b/pr_agent/algo/ai_handler.py index fcc5f04c..f5fc6722 100644 --- a/pr_agent/algo/ai_handler.py +++ b/pr_agent/algo/ai_handler.py @@ -5,7 +5,6 @@ import openai from litellm import acompletion from openai.error import APIError, RateLimitError, Timeout, TryAgain from retry import retry - from pr_agent.config_loader import get_settings OPENAI_RETRIES = 5 @@ -26,7 +25,6 @@ class AiHandler: try: openai.api_key = get_settings().openai.key litellm.openai_key = get_settings().openai.key - litellm.debugger = get_settings().config.litellm_debugger self.azure = False if get_settings().get("OPENAI.ORG", None): litellm.organization = get_settings().openai.org diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index c46412ed..9b6a3323 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -10,7 +10,6 @@ use_repo_settings_file=true ai_timeout=180 max_description_tokens = 500 max_commits_tokens = 500 -litellm_debugger=false secret_provider="google_cloud_storage" [pr_reviewer] # /review # From cd1ae55f4f22cb19da510bc95941855d13d42086 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 5 Sep 2023 15:26:45 -0700 Subject: [PATCH 2/2] bump litellm version to fix azure deployment id error --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 99efa846..6a17d715 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,7 @@ atlassian-python-api==3.39.0 GitPython~=3.1.32 PyYAML==6.0 starlette-context==0.3.6 -litellm~=0.1.504 +litellm~=0.1.538 boto3~=1.28.25 google-cloud-storage==2.10.0 ujson==5.8.0