Skip to content

Commit 1f4c095

Browse files
committed
Make llm related testing optional in CI.
1 parent 142d95b commit 1f4c095

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

tests/unit_tests/test_llm.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from opto.utils.llm import LLM
22
from opto.optimizers.utils import print_color
33

4-
try:
4+
if os.path.exists("OAI_CONFIG_LIST") or os.environ.get("DEFAULT_LITELLM_MODEL") or os.environ.get("OPENAI_API_KEY"):
55
llm = LLM()
66
system_prompt = 'You are a helpful assistant.'
77
user_prompt = "Hello world."
@@ -20,7 +20,3 @@
2020
print_color(f'System: {system_prompt}', 'red')
2121
print_color(f'User: {user_prompt}', 'blue')
2222
print_color(f'LLM: {response}', 'green')
23-
24-
except Exception as e:
25-
print_color(f'Error: {e}', 'red')
26-
print_color('Omit the test.', 'yellow')

tests/unit_tests/test_optimizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def user(x):
3434
else:
3535
return "Success."
3636

37-
if os.path.exists("OAI_CONFIG_LIST") or os.environ.get("DEFAULT_LITELLM_MODEL"):
37+
if os.path.exists("OAI_CONFIG_LIST") or os.environ.get("DEFAULT_LITELLM_MODEL") or os.environ.get("OPENAI_API_KEY"):
3838
# One-step optimization example
3939
x = node(-1.0, trainable=True)
4040
optimizer = OptoPrime([x])
@@ -124,7 +124,7 @@ def foobar_text(x):
124124
GRAPH.clear()
125125
x = node("negative point one", trainable=True)
126126

127-
if os.path.exists("OAI_CONFIG_LIST") or os.environ.get("DEFAULT_LITELLM_MODEL"):
127+
if os.path.exists("OAI_CONFIG_LIST") or os.environ.get("DEFAULT_LITELLM_MODEL") or os.environ.get("OPENAI_API_KEY"):
128128
optimizer = OptoPrime([x])
129129
output = foobar_text(x)
130130
feedback = user(output.data)

0 commit comments

Comments
 (0)