Skip to content

Commit 728232c

Browse files
Merge pull request #42 from ContextLab/claude/fix-issue-39-011CUpudsnP3nyEoc2PoFZQk
Fix SSL certificate verification issue and token limit in auto_solver
2 parents 1faf23a + 63b03bc commit 728232c

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)