Skip to content

Commit

Permalink
Merge branch 'main' into pulumi-hackweek
Browse files Browse the repository at this point in the history
  • Loading branch information
rchan26 committed Jan 4, 2024
2 parents 2dacac0 + 308d9f3 commit 27a0e2d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
16 changes: 10 additions & 6 deletions reginald/models/models/llama_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,11 +875,12 @@ def __init__(
model_name : str, optional
The model to use from the OpenAI API, by default "gpt-3.5-turbo"
"""
if os.getenv("OPENAI_API_KEY") is None:
openai_api_key = get_env_var("OPENAI_API_KEY")
if openai_api_key is None:
raise ValueError("You must set OPENAI_API_KEY for OpenAI.")

self.model_name = model_name
self.openai_api_key = get_env_var("OPENAI_API_KEY")
self.openai_api_key = openai_api_key
self.temperature = 0.7
super().__init__(*args, model_name=self.model_name, **kwargs)

Expand Down Expand Up @@ -911,18 +912,21 @@ def __init__(
model_name : str, optional
The deployment name of the model, by default "reginald-gpt35-turbo"
"""
if os.getenv("OPENAI_AZURE_API_BASE") is None:
openai_azure_api_base = get_env_var("OPENAI_AZURE_API_BASE", secret_value=False)
if openai_azure_api_base is None:
raise ValueError(
"You must set OPENAI_AZURE_API_BASE to your Azure endpoint. "
"It should look like https://YOUR_RESOURCE_NAME.openai.azure.com/"
)
if os.getenv("OPENAI_AZURE_API_KEY") is None:

openai_azure_api_key = get_env_var("OPENAI_AZURE_API_KEY")
if openai_azure_api_key is None:
raise ValueError("You must set OPENAI_AZURE_API_KEY for Azure OpenAI.")

# deployment name can be found in the Azure AI Studio portal
self.deployment_name = model_name
self.openai_api_base = get_env_var("OPENAI_AZURE_API_BASE", secret_value=False)
self.openai_api_key = get_env_var("OPENAI_AZURE_API_KEY")
self.openai_api_base = openai_azure_api_base
self.openai_api_key = openai_azure_api_key
self.openai_api_version = "2023-09-15-preview"
self.temperature = 0.7
super().__init__(*args, model_name="gpt-3.5-turbo", **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion reginald/parser_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, create_index_only: bool = False, *args, **kwargs):
Parameters
----------
create_index_only : bool, optional
Whether or not to only include ones related to data index creation,
Whether or not to only include arguments related to data index creation,
by default False
"""
super().__init__(*args, **kwargs)
Expand Down
15 changes: 9 additions & 6 deletions reginald/slack_bot/setup_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def setup_slack_bot(model: ResponseModel) -> Bot:
slack_bot = Bot(model=model)

logging.info("Connecting to Slack...")
if os.getenv("SLACK_APP_TOKEN") is None:
if get_env_var("SLACK_APP_TOKEN", log=False) is None:
logging.error("SLACK_APP_TOKEN is not set")
sys.exit(1)

Expand Down Expand Up @@ -60,7 +60,7 @@ def setup_api_slack_bot(api_url: str, emoji: str) -> ApiBot:
slack_bot = ApiBot(api_url=api_url, emoji=emoji)

logging.info("Connecting to Slack...")
if os.getenv("SLACK_APP_TOKEN") is None:
if get_env_var("SLACK_APP_TOKEN", log=False) is None:
logging.error("SLACK_APP_TOKEN is not set")
sys.exit(1)

Expand All @@ -85,19 +85,22 @@ def setup_slack_client(slack_bot: ApiBot | Bot) -> SocketModeClient:
SocketModeClient
Slack client with bot
"""
if os.getenv("SLACK_APP_TOKEN") is None:
slack_app_token = get_env_var("SLACK_APP_TOKEN")
if slack_app_token is None:
logging.error("SLACK_APP_TOKEN is not set")
sys.exit(1)
if os.getenv("SLACK_BOT_TOKEN") is None:

slack_bot_token = get_env_var("SLACK_BOT_TOKEN")
if slack_bot_token is None:
logging.error("SLACK_BOT_TOKEN is not set")
sys.exit(1)

# initialize SocketModeClient with an app-level token + AsyncWebClient
client = SocketModeClient(
# this app-level token will be used only for establishing a connection
app_token=get_env_var("SLACK_APP_TOKEN"),
app_token=slack_app_token,
# you will be using this AsyncWebClient for performing Web API calls in listeners
web_client=AsyncWebClient(token=get_env_var("SLACK_BOT_TOKEN")),
web_client=AsyncWebClient(token=slack_bot_token),
# to ensure connection doesn't go stale - we can adjust as needed.
ping_interval=60,
)
Expand Down

0 comments on commit 27a0e2d

Please sign in to comment.