Skip to content

Commit 94c59e7

Browse files
committed
Fix OpenAI() instantiation bug
1 parent 439d09d commit 94c59e7

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

operate/config.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,26 @@ def __init__(self):
3535
)
3636

3737
def initialize_openai(self):
38-
client = OpenAI()
38+
if self.verbose:
39+
print("[Config][initialize_openai]")
40+
3941
if self.openai_api_key:
4042
if self.verbose:
4143
print("[Config][initialize_openai] using cached openai_api_key")
4244
api_key = self.openai_api_key
4345
else:
44-
print(
45-
"[Config][initialize_openai] no cached openai_api_key, try to get from env."
46-
)
46+
if self.verbose:
47+
print(
48+
"[Config][initialize_openai] no cached openai_api_key, try to get from env."
49+
)
4750
api_key = os.getenv("OPENAI_API_KEY")
51+
52+
if self.verbose:
53+
print("[Config][initialize_openai] api_key", api_key)
54+
55+
client = OpenAI(
56+
api_key=api_key,
57+
)
4858
client.api_key = api_key
4959
client.base_url = os.getenv("OPENAI_API_BASE_URL", client.base_url)
5060
return client

operate/models/apis.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
async def get_next_action(model, messages, objective, session_id):
4343
if VERBOSE:
4444
print("[Self-Operating Computer][get_next_action]")
45-
print("[Self-Operating Computer][get_next_action] VERBOSE", VERBOSE)
46-
print("[Self-Operating Computer][get_next_action] config", config)
4745
print("[Self-Operating Computer][get_next_action] model", model)
4846
if model == "gpt-4":
4947
return call_gpt_4_vision_preview(messages), None

0 commit comments

Comments
 (0)