-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standardizing environment for completions and embeddings (#46)
* standardizing environment for completions and embeddings * pr feedback * build pipeline fixes * renaming default_values module * renaming tests
- Loading branch information
Showing
12 changed files
with
217 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT license. | ||
|
||
import os | ||
import pytest | ||
|
||
from pyrit.completion import AzureCompletion | ||
|
||
|
||
def test_valid_init(): | ||
os.environ[AzureCompletion.API_KEY_ENVIRONMENT_VARIABLE] = "" | ||
completion = AzureCompletion(api_key="xxxxx", endpoint="https://mock.azure.com/", deployment="gpt-4") | ||
|
||
assert completion is not None | ||
|
||
|
||
def test_valid_init_env(): | ||
os.environ[AzureCompletion.API_KEY_ENVIRONMENT_VARIABLE] = "xxxxx" | ||
os.environ[AzureCompletion.ENDPOINT_URI_ENVIRONMENT_VARIABLE] = "https://testcompletionendpoint" | ||
os.environ[AzureCompletion.DEPLOYMENT_ENVIRONMENT_VARIABLE] = "testcompletiondeployment" | ||
|
||
completion = AzureCompletion() | ||
assert completion is not None | ||
|
||
|
||
def test_invalid_key_raises(): | ||
os.environ[AzureCompletion.API_KEY_ENVIRONMENT_VARIABLE] = "" | ||
with pytest.raises(ValueError): | ||
AzureCompletion( | ||
api_key="", | ||
endpoint="https://mock.azure.com/", | ||
deployment="gpt-4", | ||
api_version="some_version", | ||
) | ||
|
||
|
||
def test_invalid_endpoint_raises(): | ||
os.environ[AzureCompletion.ENDPOINT_URI_ENVIRONMENT_VARIABLE] = "" | ||
with pytest.raises(ValueError): | ||
AzureCompletion( | ||
api_key="xxxxxx", | ||
deployment="gpt-4", | ||
api_version="some_version", | ||
) | ||
|
||
|
||
def test_invalid_deployment_raises(): | ||
os.environ[AzureCompletion.DEPLOYMENT_ENVIRONMENT_VARIABLE] = "" | ||
with pytest.raises(ValueError): | ||
AzureCompletion( | ||
api_key="", | ||
endpoint="https://mock.azure.com/", | ||
) |
Oops, something went wrong.