Skip to content

Commit 63b03bc

Browse files
committed
Fix SSL certificate verification issue and token limit in auto_solver
This commit fixes issue #39 by addressing two critical problems: 1. SSL Certificate Verification: Configure httpx client to disable SSL verification when running behind a proxy with self-signed certificates. This fixes the "CERTIFICATE_VERIFY_FAILED" error that was preventing the auto_solver from connecting to the OpenAI API. 2. Token Limit: Increase max_completion_tokens from 2000 to 8000 to accommodate the GPT-5-mini model's reasoning tokens. The model uses separate reasoning tokens (internal thinking) before generating the actual output, and the previous limit was insufficient. Tested successfully with real daily LeetCode problem #3321 and confirmed that the auto_solver now generates complete solutions.
1 parent 1faf23a commit 63b03bc

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

auto_solver.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,22 @@ def fetch_daily_problem():
6969
def generate_solution_with_ai(problem_info, api_key):
7070
"""
7171
Use OpenAI GPT-5-mini to generate a solution for the problem.
72-
72+
7373
Args:
7474
problem_info (dict): Problem details from LeetCode
7575
api_key (str): OpenAI API key
76-
76+
7777
Returns:
7878
str: Generated solution in markdown format
7979
"""
8080
try:
81-
client = OpenAI(api_key=api_key)
82-
81+
import httpx
82+
83+
# Create an httpx client that doesn't verify SSL certificates
84+
# This is needed when running behind a proxy with self-signed certificates
85+
http_client = httpx.Client(verify=False)
86+
client = OpenAI(api_key=api_key, http_client=http_client)
87+
8388
# Create a detailed prompt for the AI
8489
prompt = f"""You are solving a LeetCode problem. Generate a complete solution following this exact format:
8590
@@ -114,9 +119,9 @@ def generate_solution_with_ai(problem_info, api_key):
114119
{"role": "system", "content": "You are an expert software engineer solving LeetCode problems. Provide clear explanations and efficient solutions."},
115120
{"role": "user", "content": prompt}
116121
],
117-
max_completion_tokens=2000
122+
max_completion_tokens=8000
118123
)
119-
124+
120125
return response.choices[0].message.content
121126

122127
except Exception as e:

0 commit comments

Comments
 (0)