langchain/libs/partners/openai/tests/unit_tests/test_secrets.py
2024-01-30 15:49:56 -08:00

63 lines
1.3 KiB
Python

from langchain_openai import (
AzureChatOpenAI,
AzureOpenAI,
AzureOpenAIEmbeddings,
ChatOpenAI,
OpenAI,
OpenAIEmbeddings,
)
def test_chat_openai_secrets() -> None:
o = ChatOpenAI(openai_api_key="foo")
s = str(o)
assert "foo" not in s
def test_openai_secrets() -> None:
o = OpenAI(openai_api_key="foo")
s = str(o)
assert "foo" not in s
def test_openai_embeddings_secrets() -> None:
o = OpenAIEmbeddings(openai_api_key="foo")
s = str(o)
assert "foo" not in s
def test_azure_chat_openai_secrets() -> None:
o = AzureChatOpenAI(
openai_api_key="foo1",
azure_endpoint="endpoint",
azure_ad_token="foo2",
api_version="version",
)
s = str(o)
assert "foo1" not in s
assert "foo2" not in s
def test_azure_openai_secrets() -> None:
o = AzureOpenAI(
openai_api_key="foo1",
azure_endpoint="endpoint",
azure_ad_token="foo2",
api_version="version",
)
s = str(o)
assert "foo1" not in s
assert "foo2" not in s
def test_azure_openai_embeddings_secrets() -> None:
o = AzureOpenAIEmbeddings(
openai_api_key="foo1",
azure_endpoint="endpoint",
azure_ad_token="foo2",
api_version="version",
)
s = str(o)
assert "foo1" not in s
assert "foo2" not in s