From b94734e69a4b3466fefe20bbdb467a504840fd48 Mon Sep 17 00:00:00 2001 From: Ori Kotek Date: Thu, 6 Jul 2023 09:52:01 +0300 Subject: [PATCH] Add support for OpenAI organization in the secrets file --- pr_agent/algo/ai_handler.py | 2 ++ pr_agent/settings/.secrets_template.toml | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pr_agent/algo/ai_handler.py b/pr_agent/algo/ai_handler.py index 2dd8f731..a774e105 100644 --- a/pr_agent/algo/ai_handler.py +++ b/pr_agent/algo/ai_handler.py @@ -12,6 +12,8 @@ class AiHandler: def __init__(self): try: openai.api_key = settings.openai.key + if settings.get("OPENAI.ORG", None): + openai.organization = settings.openai.org except AttributeError as e: raise ValueError("OpenAI key is required") from e diff --git a/pr_agent/settings/.secrets_template.toml b/pr_agent/settings/.secrets_template.toml index 91aa275a..59f4625b 100644 --- a/pr_agent/settings/.secrets_template.toml +++ b/pr_agent/settings/.secrets_template.toml @@ -7,7 +7,8 @@ # See README for details about GitHub App deployment. [openai] -key = "" +key = "" # Acquire through https://platform.openai.com +org = "" # Optional, may be commented out. [github] # The type of deployment to create. Valid values are 'app' or 'user'.