Skip to content

Commit 99a6ba8

Browse files
committed
Fix openai API usage.
1 parent da98893 commit 99a6ba8

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

.env.example

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
OPENAI_API_KEY=sk-XXXX
2-
OPENAI_API_TYPE=openai
3-
OPENAI_BASE_URL=https://api.openai.com
2+
OPENAI_API_TYPE=open_ai
3+
OPENAI_BASE_URL=https://api.openai.com/v1
44
OPENAI_API_VERSION=2023-03-15-preview
55
# OPENAI_EXTRA_HEADERS={"key": "value"}
66
OPENAI_MODELS=[{"displayName": "GPT-3.5", "name": "gpt-3.5-turbo"}, {"displayName": "GPT-4", "name": "gpt-4"}]

gpt_code_ui/webapp/main.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@
1919

2020
load_dotenv('.env')
2121

22-
openai.api_base = os.environ.get("OPENAI_BASE_URL", "https://api.openai.com")
23-
openai.api_type = os.environ.get("OPENAI_API_TYPE", "openai")
2422
openai.api_version = os.environ.get("OPENAI_API_VERSION")
25-
openai.api_key = os.environ.get("OPENAI_API_KEY", "")
26-
openai.log = os.getenv("OPENAI_API_LOGLEVEL", "")
23+
openai.log = os.getenv("OPENAI_API_LOGLEVEL")
2724
OPENAI_EXTRA_HEADERS = json.loads(os.environ.get("OPENAI_EXTRA_HEADERS", "{}"))
2825

29-
if openai.api_type == "openai":
26+
if openai.api_type == "open_ai":
3027
AVAILABLE_MODELS = json.loads(os.environ.get("OPENAI_MODELS", '''[{"displayName": "GPT-3.5", "name": "gpt-3.5-turbo"}, {"displayName": "GPT-4", "name": "gpt-4"}]'''))
3128
elif openai.api_type == "azure":
3229
try:
@@ -138,7 +135,7 @@ async def get_code(user_prompt, user_openai_key=None, model="gpt-3.5-turbo"):
138135
]
139136
)
140137

141-
if openai.api_type == 'openai':
138+
if openai.api_type == 'open_ai':
142139
arguments["model"] = model
143140
elif openai.api_type == 'azure':
144141
arguments["deployment_id"] = model

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setup(
99
name='gpt_code_ui',
10-
version='0.42.38',
10+
version='0.42.39',
1111
description="An Open Source version of ChatGPT Code Interpreter",
1212
long_description=long_description,
1313
long_description_content_type='text/markdown', # This field specifies the format of the `long_description`.

0 commit comments

Comments
 (0)