Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions auto_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,22 @@ def fetch_daily_problem():
def generate_solution_with_ai(problem_info, api_key):
"""
Use OpenAI GPT-5-mini to generate a solution for the problem.

Args:
problem_info (dict): Problem details from LeetCode
api_key (str): OpenAI API key

Returns:
str: Generated solution in markdown format
"""
try:
client = OpenAI(api_key=api_key)

import httpx

# Create an httpx client that doesn't verify SSL certificates
# This is needed when running behind a proxy with self-signed certificates
http_client = httpx.Client(verify=False)
client = OpenAI(api_key=api_key, http_client=http_client)

# Create a detailed prompt for the AI
prompt = f"""You are solving a LeetCode problem. Generate a complete solution following this exact format:

Expand Down Expand Up @@ -114,9 +119,9 @@ def generate_solution_with_ai(problem_info, api_key):
{"role": "system", "content": "You are an expert software engineer solving LeetCode problems. Provide clear explanations and efficient solutions."},
{"role": "user", "content": prompt}
],
max_completion_tokens=2000
max_completion_tokens=8000
)

return response.choices[0].message.content

except Exception as e:
Expand Down