Skip to content

Commit c23159b

Browse files
committed
fix 'Expected 3 values to unpack but got 2' error in case the API call fails
1 parent 6bdc463 commit c23159b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

gpt_code_ui/webapp/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ async def get_code(user_prompt, user_openai_key=None, model="gpt-3.5-turbo"):
130130
headers=headers,
131131
)
132132
else:
133-
return "Error: Invalid OPENAI_PROVIDER", 500
133+
return None, "Error: Invalid OPENAI_PROVIDER", 500
134134

135135

136136
def extract_code(text):
@@ -153,7 +153,7 @@ def extract_non_code(text):
153153

154154

155155
if response.status_code != 200:
156-
return "Error: " + response.text, 500
156+
return None, "Error: " + response.text, 500
157157

158158
content = response.json()["choices"][0]["message"]["content"]
159159
return extract_code(content), extract_non_code(content), 200

0 commit comments

Comments
 (0)