Enhanced mock OpenAI client for IMO25 testing
| 19 | |
| 20 | |
| 21 | class MockOpenAIClient: |
| 22 | """Enhanced mock OpenAI client for IMO25 testing""" |
| 23 | |
| 24 | def __init__(self, response_delay=0.1, reasoning_tokens=2000): |
| 25 | self.response_delay = response_delay |
| 26 | self.reasoning_tokens = reasoning_tokens |
| 27 | self.call_count = 0 |
| 28 | self.call_times = [] |
| 29 | |
| 30 | def chat_completions_create(self, **kwargs): |
| 31 | """Mock completions.create with realistic IMO25 responses""" |
| 32 | start_time = time.time() |
| 33 | time.sleep(self.response_delay) |
| 34 | self.call_count += 1 |
| 35 | self.call_times.append(time.time()) |
| 36 | |
| 37 | call_count = self.call_count |
| 38 | |
| 39 | class MockUsage: |
| 40 | def __init__(self, reasoning_tokens): |
| 41 | self.completion_tokens_details = type('obj', (), { |
| 42 | 'reasoning_tokens': reasoning_tokens |
| 43 | })() |
| 44 | self.total_tokens = reasoning_tokens + 200 |
| 45 | |
| 46 | class MockChoice: |
| 47 | def __init__(self, content): |
| 48 | self.message = type('obj', (), { |
| 49 | 'content': content |
| 50 | })() |
| 51 | |
| 52 | class MockResponse: |
| 53 | def __init__(self, content, reasoning_tokens): |
| 54 | self.choices = [MockChoice(content)] |
| 55 | self.usage = MockUsage(reasoning_tokens) |
| 56 | |
| 57 | # Get problem content from messages |
| 58 | messages = kwargs.get('messages', []) |
| 59 | problem_content = "" |
| 60 | for message in messages: |
| 61 | problem_content += message.get('content', '') |
| 62 | |
| 63 | # Generate appropriate responses based on problem content and call type |
| 64 | if "verifying" in problem_content.lower(): |
| 65 | # Verification response |
| 66 | content = f"VERIFICATION: This solution appears CORRECT. The analysis is mathematically sound and the final answer is properly justified. Confidence: 8/10." |
| 67 | elif "improving" in problem_content.lower(): |
| 68 | # Improvement response |
| 69 | content = f"IMPROVEMENT: The original approach is good but can be enhanced. Here's the improved version with stronger reasoning..." |
| 70 | elif "bonza" in problem_content.lower(): |
| 71 | # IMO25 Problem 3 - functional equation |
| 72 | responses = [ |
| 73 | "Looking at this functional equation problem, I need to find the smallest constant c such that f(n) ≤ cn for all bonza functions f. Let me analyze the divisibility condition: f(a) divides b^a - f(b)^f(a). This is a complex functional equation. After careful analysis of the constraints, I believe the minimum constant is c = 4. This can be shown by constructing specific examples and proving upper bounds.", |
| 74 | "For the bonza function problem, I'll work through the case analysis systematically. A function f: ℕ → ℕ is bonza if f(a) | (b^a - f(b)^f(a)) for all positive integers a,b. Through detailed analysis of the divisibility constraints and construction of extremal examples, the smallest real constant c such that f(n) ≤ cn for all bonza functions is c = 4.", |
| 75 | "This functional equation requires careful analysis. I'll examine when f(a) divides b^a - f(b)^f(a). By studying specific cases and constructing examples, I can show that the minimal constant c = 4 is both necessary and sufficient. The answer is c = 4." |
| 76 | ] |
| 77 | content = responses[call_count % len(responses)] |
| 78 | elif "three largest proper divisors" in problem_content.lower(): |
no outgoing calls