Skip to content

Commit 8a507bc

Browse files
committed
Set env vars for tests
1 parent 2764e15 commit 8a507bc

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

tests/llm/test_models.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,40 @@
77
from controlflow.llm.models import get_model
88

99

10-
def test_get_model_from_openai():
10+
def test_get_model_from_openai(monkeypatch):
11+
monkeypatch.setenv("OPENAI_API_KEY", "fake_openai_api_key")
1112
model = get_model("openai/gpt-4o-mini")
1213
assert isinstance(model, ChatOpenAI)
1314
assert model.model_name == "gpt-4o-mini"
1415

1516

16-
def test_get_model_from_anthropic():
17+
def test_get_model_from_anthropic(monkeypatch):
18+
monkeypatch.setenv("ANTHROPIC_API_KEY", "fake_anthropic_api_key")
1719
model = get_model("anthropic/claude-3-haiku-20240307")
1820
assert isinstance(model, ChatAnthropic)
1921
assert model.model == "claude-3-haiku-20240307"
2022

2123

22-
def test_get_azure_openai_model():
24+
def test_get_azure_openai_model(monkeypatch):
25+
monkeypatch.setenv("AZURE_OPENAI_API_KEY", "fake_azure_openai_api_key")
26+
monkeypatch.setenv(
27+
"AZURE_OPENAI_ENDPOINT", "https://fake-endpoint.openai.azure.com"
28+
)
29+
monkeypatch.setenv("OPENAI_API_VERSION", "2024-05-01-preview")
2330
model = get_model("azure-openai/gpt-4")
2431
assert isinstance(model, AzureChatOpenAI)
25-
assert model.deployment_name == "gpt-4"
32+
assert model.model_name == "gpt-4"
2633

2734

28-
def test_get_google_model():
35+
def test_get_google_model(monkeypatch):
36+
monkeypatch.setenv("GOOGLE_API_KEY", "fake_google_api_key")
2937
model = get_model("google/gemini-1.5-pro")
3038
assert isinstance(model, ChatGoogleGenerativeAI)
3139
assert model.model == "models/gemini-1.5-pro"
3240

3341

34-
def test_get_groq_model():
42+
def test_get_groq_model(monkeypatch):
43+
monkeypatch.setenv("GROQ_API_KEY", "fake_groq_api_key")
3544
model = get_model("groq/mixtral-8x7b-32768")
3645
assert isinstance(model, ChatGroq)
3746
assert model.model_name == "mixtral-8x7b-32768"
@@ -49,7 +58,8 @@ def test_get_model_with_unsupported_provider():
4958
get_model("unsupported/model-name")
5059

5160

52-
def test_get_model_with_temperature():
61+
def test_get_model_with_temperature(monkeypatch):
62+
monkeypatch.setenv("ANTHROPIC_API_KEY", "fake_anthropic_api_key")
5363
model = get_model("anthropic/claude-3-haiku-20240307", temperature=0.7)
5464
assert isinstance(model, ChatAnthropic)
5565
assert model.temperature == 0.7

0 commit comments

Comments
 (0)