-
Notifications
You must be signed in to change notification settings - Fork 15.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use secretstr for api keys for javelin-ai-gateway (#13417)
- Make javelin_ai_gateway_api_key a SecretStr --------- Co-authored-by: Hiroshi Tashiro <[email protected]>
- Loading branch information
1 parent
ba501b2
commit accadcc
Showing
4 changed files
with
79 additions
and
31 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
32 changes: 32 additions & 0 deletions
32
libs/langchain/tests/unit_tests/chat_models/test_javelin_ai_gateway.py
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,32 @@ | ||
"""Test `Javelin AI Gateway` chat models""" | ||
|
||
import pytest | ||
|
||
from langchain.chat_models import ChatJavelinAIGateway | ||
from langchain.pydantic_v1 import SecretStr | ||
|
||
|
||
@pytest.mark.requires("javelin_sdk") | ||
def test_api_key_is_secret_string() -> None: | ||
llm = ChatJavelinAIGateway( | ||
gateway_uri="<javelin-ai-gateway-uri>", | ||
route="<javelin-ai-gateway-chat-route>", | ||
javelin_api_key="secret-api-key", | ||
params={"temperature": 0.1}, | ||
) | ||
assert isinstance(llm.javelin_api_key, SecretStr) | ||
assert llm.javelin_api_key.get_secret_value() == "secret-api-key" | ||
|
||
|
||
@pytest.mark.requires("javelin_sdk") | ||
def test_api_key_masked_when_passed_via_constructor() -> None: | ||
llm = ChatJavelinAIGateway( | ||
gateway_uri="<javelin-ai-gateway-uri>", | ||
route="<javelin-ai-gateway-chat-route>", | ||
javelin_api_key="secret-api-key", | ||
params={"temperature": 0.1}, | ||
) | ||
|
||
assert str(llm.javelin_api_key) == "**********" | ||
assert "secret-api-key" not in repr(llm.javelin_api_key) | ||
assert "secret-api-key" not in repr(llm) |