File tree Expand file tree Collapse file tree 2 files changed +3
-7
lines changed Expand file tree Collapse file tree 2 files changed +3
-7
lines changed Original file line number Diff line number Diff line change 1
1
from opto .utils .llm import LLM
2
2
from opto .optimizers .utils import print_color
3
3
4
- try :
4
+ if os . path . exists ( "OAI_CONFIG_LIST" ) or os . environ . get ( "DEFAULT_LITELLM_MODEL" ) or os . environ . get ( "OPENAI_API_KEY" ) :
5
5
llm = LLM ()
6
6
system_prompt = 'You are a helpful assistant.'
7
7
user_prompt = "Hello world."
20
20
print_color (f'System: { system_prompt } ' , 'red' )
21
21
print_color (f'User: { user_prompt } ' , 'blue' )
22
22
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' )
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ def user(x):
34
34
else :
35
35
return "Success."
36
36
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" ) :
38
38
# One-step optimization example
39
39
x = node (- 1.0 , trainable = True )
40
40
optimizer = OptoPrime ([x ])
@@ -124,7 +124,7 @@ def foobar_text(x):
124
124
GRAPH .clear ()
125
125
x = node ("negative point one" , trainable = True )
126
126
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" ) :
128
128
optimizer = OptoPrime ([x ])
129
129
output = foobar_text (x )
130
130
feedback = user (output .data )
You can’t perform that action at this time.
0 commit comments