Tecnhotron commited on
Commit
40ada9b
·
1 Parent(s): e78c9e1
__pycache__/computer_control_helper.cpython-313.pyc DELETED
Binary file (24.4 kB)
 
__pycache__/streaming.cpython-313.pyc DELETED
Binary file (15.4 kB)
 
__pycache__/test_api.cpython-313-pytest-8.3.5.pyc DELETED
Binary file (9.06 kB)
 
lmarena.log DELETED
@@ -1,790 +0,0 @@
1
- 2025-06-09 12:15:57,895 - __main__ - INFO - Configuration loaded.
2
- 2025-06-09 12:15:57,902 - __main__ - INFO - DriverManager instance created.
3
- 2025-06-09 12:15:58,475 - __main__ - INFO - Gemini client initialized successfully.
4
- 2025-06-09 12:15:58,532 - __main__ - INFO - GEMINI_API_KEY is set.
5
- 2025-06-09 12:15:58,532 - __main__ - INFO - Starting Uvicorn server on 0.0.0.0:8000.
6
- 2025-06-09 12:15:58,569 - __main__ - INFO - Application startup sequence initiated.
7
- 2025-06-09 12:15:58,570 - __main__ - INFO - Initializing Selenium driver...
8
- 2025-06-09 12:15:58,572 - __main__ - INFO - Executing synchronous driver initialization and enhanced readiness check.
9
- 2025-06-09 12:16:02,376 - __main__ - INFO - Driver instantiated. Opening URL...
10
- 2025-06-09 12:16:07,588 - __main__ - INFO - URL 'https://beta.lmarena.ai/?mode=direct' opened.
11
- 2025-06-09 12:16:07,589 - __main__ - INFO - Attempting to solve initial (Cloudflare-style) captcha with uc_gui_click_captcha()...
12
- 2025-06-09 12:16:23,430 - __main__ - INFO - uc_gui_click_captcha() completed. Main site should be loading now.
13
- 2025-06-09 12:16:23,431 - __main__ - INFO - Checking for on-site ('Verify Human') captcha...
14
- 2025-06-09 12:16:27,502 - __main__ - WARNING - Unexpected error checking UI state for on-site captcha: Message: invalid session id: session deleted as the browser has closed the connection
15
- from disconnected: not connected to DevTools
16
- (Session info: chrome=137.0.7151.69)
17
- Stacktrace:
18
- GetHandleVerifier [0x0x7ff748e66f65+78965]
19
- GetHandleVerifier [0x0x7ff748e66fc0+79056]
20
- (No symbol) [0x0x7ff748bf9dda]
21
- (No symbol) [0x0x7ff748be5bc5]
22
- (No symbol) [0x0x7ff748c0ac04]
23
- (No symbol) [0x0x7ff748c80195]
24
- (No symbol) [0x0x7ff748ca06cd]
25
- (No symbol) [0x0x7ff748c78443]
26
- (No symbol) [0x0x7ff748c41311]
27
- (No symbol) [0x0x7ff748c420a3]
28
- GetHandleVerifier [0x0x7ff74911e26d+2926461]
29
- GetHandleVerifier [0x0x7ff749118993+2903715]
30
- GetHandleVerifier [0x0x7ff749136aed+3026941]
31
- GetHandleVerifier [0x0x7ff748e816fe+187406]
32
- GetHandleVerifier [0x0x7ff748e896ef+220159]
33
- GetHandleVerifier [0x0x7ff748e6faf4+114692]
34
- GetHandleVerifier [0x0x7ff748e6fca9+115129]
35
- GetHandleVerifier [0x0x7ff748e564d8+10728]
36
- BaseThreadInitThunk [0x0x7ffd6f06e8d7+23]
37
- RtlUserThreadStart [0x0x7ffd6fafc5dc+44]
38
- Traceback (most recent call last):
39
- File "c:\Users\caree\Code\Lmarena\api.py", line 186, in _perform_sync_captcha_checks
40
- textarea = WebDriverWait(driver, 5).until(EC.element_to_be_clickable(textarea_locator))
41
- File "C:\Users\caree\AppData\Local\Programs\Python\Python313\Lib\site-packages\selenium\webdriver\support\wait.py", line 129, in until
42
- value = method(self._driver)
43
- File "C:\Users\caree\AppData\Local\Programs\Python\Python313\Lib\site-packages\selenium\webdriver\support\expected_conditions.py", line 622, in _predicate
44
- target = driver.find_element(*target) # grab element at locator
45
- File "C:\Users\caree\AppData\Local\Programs\Python\Python313\Lib\site-packages\seleniumbase\core\sb_driver.py", line 27, in find_element
46
- return self.driver.default_find_element(by=by, value=value)
47
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
48
- File "C:\Users\caree\AppData\Local\Programs\Python\Python313\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 914, in find_element
49
- return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
50
- ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
51
- File "C:\Users\caree\AppData\Local\Programs\Python\Python313\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 447, in execute
52
- self.error_handler.check_response(response)
53
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
54
- File "C:\Users\caree\AppData\Local\Programs\Python\Python313\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 232, in check_response
55
- raise exception_class(message, screen, stacktrace)
56
- selenium.common.exceptions.InvalidSessionIdException: Message: invalid session id: session deleted as the browser has closed the connection
57
- from disconnected: not connected to DevTools
58
- (Session info: chrome=137.0.7151.69)
59
- Stacktrace:
60
- GetHandleVerifier [0x0x7ff748e66f65+78965]
61
- GetHandleVerifier [0x0x7ff748e66fc0+79056]
62
- (No symbol) [0x0x7ff748bf9dda]
63
- (No symbol) [0x0x7ff748be5bc5]
64
- (No symbol) [0x0x7ff748c0ac04]
65
- (No symbol) [0x0x7ff748c80195]
66
- (No symbol) [0x0x7ff748ca06cd]
67
- (No symbol) [0x0x7ff748c78443]
68
- (No symbol) [0x0x7ff748c41311]
69
- (No symbol) [0x0x7ff748c420a3]
70
- GetHandleVerifier [0x0x7ff74911e26d+2926461]
71
- GetHandleVerifier [0x0x7ff749118993+2903715]
72
- GetHandleVerifier [0x0x7ff749136aed+3026941]
73
- GetHandleVerifier [0x0x7ff748e816fe+187406]
74
- GetHandleVerifier [0x0x7ff748e896ef+220159]
75
- GetHandleVerifier [0x0x7ff748e6faf4+114692]
76
- GetHandleVerifier [0x0x7ff748e6fca9+115129]
77
- GetHandleVerifier [0x0x7ff748e564d8+10728]
78
- BaseThreadInitThunk [0x0x7ffd6f06e8d7+23]
79
- RtlUserThreadStart [0x0x7ffd6fafc5dc+44]
80
-
81
- 2025-06-09 12:16:27,507 - __main__ - INFO - Starting visual AI check for on-site captcha.
82
- 2025-06-09 12:16:27,663 - __main__ - INFO - Sending screenshot to Gemini API for analysis.
83
- 2025-06-09 12:16:27,663 - google_genai.models - INFO - AFC is enabled with max remote calls: 10.
84
- 2025-06-09 12:16:27,664 - google_genai.models - INFO - AFC remote call 1 is done.
85
- 2025-06-09 12:16:30,777 - httpx - INFO - HTTP Request: POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:streamGenerateContent?alt=sse "HTTP/1.1 200 OK"
86
- 2025-06-09 12:16:30,849 - __main__ - INFO - Received Gemini response for on-site captcha check: ```json
87
- [
88
- {"box_2d": [495, 138, 527, 151], "label": "box"}
89
- ]
90
- ```
91
- 2025-06-09 12:16:30,849 - __main__ - INFO - On-site captcha checkbox found via Gemini. Clicking coordinates: {'box_2d': [495, 138, 527, 151], 'label': 'box'}
92
- 2025-06-09 12:16:42,537 - __main__ - INFO - Configuration loaded.
93
- 2025-06-09 12:16:42,542 - __main__ - INFO - DriverManager instance created.
94
- 2025-06-09 12:16:43,027 - __main__ - INFO - Gemini client initialized successfully.
95
- 2025-06-09 12:16:43,065 - __main__ - INFO - GEMINI_API_KEY is set.
96
- 2025-06-09 12:16:43,065 - __main__ - INFO - Starting Uvicorn server on 0.0.0.0:8000.
97
- 2025-06-09 12:16:43,090 - __main__ - INFO - Application startup sequence initiated.
98
- 2025-06-09 12:16:43,091 - __main__ - INFO - Initializing Selenium driver...
99
- 2025-06-09 12:16:43,092 - __main__ - INFO - Executing synchronous driver initialization and enhanced readiness check.
100
- 2025-06-09 12:16:46,172 - __main__ - INFO - Driver instantiated. Opening URL...
101
- 2025-06-09 12:16:53,140 - __main__ - INFO - URL 'https://beta.lmarena.ai/?mode=direct' opened.
102
- 2025-06-09 12:16:53,141 - __main__ - INFO - Attempting to solve initial (Cloudflare-style) captcha with uc_gui_click_captcha()...
103
- 2025-06-09 12:16:53,588 - __main__ - INFO - uc_gui_click_captcha() completed. Main site should be loading now.
104
- 2025-06-09 12:16:53,589 - __main__ - INFO - Checking for on-site ('Verify Human') captcha...
105
- 2025-06-09 12:16:55,688 - __main__ - INFO - No on-site captcha detected. Main UI is ready.
106
- 2025-06-09 12:16:55,688 - __main__ - INFO - Selenium driver initialization process completed successfully.
107
- 2025-06-09 12:16:55,689 - __main__ - INFO - Application startup sequence completed successfully.
108
- 2025-06-09 12:17:39,593 - __main__ - INFO - Application shutdown sequence initiated.
109
- 2025-06-09 12:17:39,593 - __main__ - INFO - Cleaning up and quitting Selenium driver...
110
- 2025-06-09 12:17:41,909 - __main__ - INFO - Driver quit successfully.
111
- 2025-06-09 12:17:41,909 - __main__ - INFO - Application shutdown sequence completed.
112
- 2025-06-09 12:18:55,881 - __main__ - INFO - Configuration loaded.
113
- 2025-06-09 12:18:55,887 - __main__ - INFO - DriverManager instance created.
114
- 2025-06-09 12:18:56,388 - __main__ - INFO - Gemini client initialized successfully.
115
- 2025-06-09 12:18:56,424 - __main__ - INFO - GEMINI_API_KEY is set.
116
- 2025-06-09 12:18:56,425 - __main__ - INFO - Starting Uvicorn server on 0.0.0.0:8000.
117
- 2025-06-09 12:18:56,450 - __main__ - INFO - Application startup sequence initiated.
118
- 2025-06-09 12:18:56,451 - __main__ - INFO - Initializing Selenium driver...
119
- 2025-06-09 12:18:56,452 - __main__ - INFO - Executing synchronous driver initialization and enhanced readiness check.
120
- 2025-06-09 12:18:59,568 - __main__ - INFO - Driver instantiated. Opening URL...
121
- 2025-06-09 12:19:07,244 - __main__ - INFO - URL 'https://beta.lmarena.ai/?mode=direct' opened.
122
- 2025-06-09 12:19:07,244 - __main__ - INFO - Attempting to solve initial (Cloudflare-style) captcha with uc_gui_click_captcha()...
123
- 2025-06-09 12:19:07,251 - __main__ - INFO - uc_gui_click_captcha() completed. Main site should be loading now.
124
- 2025-06-09 12:19:07,252 - __main__ - INFO - Checking for on-site ('Verify Human') captcha...
125
- 2025-06-09 12:19:12,372 - __main__ - INFO - Chat input textarea not interactable. Proceeding with AI captcha solver.
126
- 2025-06-09 12:19:12,374 - __main__ - INFO - Starting visual AI check for on-site captcha.
127
- 2025-06-09 12:19:12,539 - __main__ - INFO - Sending screenshot to Gemini API for analysis.
128
- 2025-06-09 12:19:12,539 - google_genai.models - INFO - AFC is enabled with max remote calls: 10.
129
- 2025-06-09 12:19:12,539 - google_genai.models - INFO - AFC remote call 1 is done.
130
- 2025-06-09 12:19:15,352 - httpx - INFO - HTTP Request: POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:streamGenerateContent?alt=sse "HTTP/1.1 200 OK"
131
- 2025-06-09 12:19:15,478 - __main__ - INFO - Received Gemini response for on-site captcha check: ```json
132
- [
133
- {"box_2d": [578, 166, 612, 185], "label": "box"}
134
- ]
135
- ```
136
- 2025-06-09 12:19:15,478 - __main__ - INFO - On-site captcha checkbox found via Gemini. Clicking coordinates: {'box_2d': [578, 166, 612, 185], 'label': 'box'}
137
- 2025-06-09 12:19:19,272 - __main__ - INFO - Click performed. Now reloading page as requested for post-AI solve.
138
- 2025-06-09 12:19:19,272 - __main__ - INFO - Performing human-like page reload
139
- 2025-06-09 12:19:19,273 - __main__ - INFO - Using FN+F5 key combination
140
- 2025-06-09 12:19:21,438 - __main__ - INFO - Page reloaded after 1.26s delay
141
- 2025-06-09 12:19:26,439 - __main__ - INFO - Selenium driver initialization process completed successfully.
142
- 2025-06-09 12:19:26,439 - __main__ - INFO - Application startup sequence completed successfully.
143
- 2025-06-09 12:19:44,775 - __main__ - INFO - [chatcmpl-1503f2e8146f468993892ee257265847] Received chat completion request: model='qwen no think', stream=True, md_convert=True
144
- 2025-06-09 12:19:44,788 - streaming - INFO - [chatcmpl-1503f2e8146f468993892ee257265847] Starting streaming response generation for model 'qwen no think'.
145
- 2025-06-09 12:19:44,788 - __main__ - INFO - [98806519-9b36-4d7a-9c31-66529703a72f] Starting chat. Model: 'qwen no think', RawHTML: False, MarkdownMode: True.
146
- 2025-06-09 12:19:44,788 - __main__ - INFO - Selecting model: qwen no think
147
- 2025-06-09 12:19:45,064 - __main__ - INFO - Selected model: qwen no think
148
- 2025-06-09 12:19:45,065 - __main__ - INFO - [98806519-9b36-4d7a-9c31-66529703a72f] Sending prompt (first 50 chars): 'python pascals tree gen small concise code no comm...'
149
- 2025-06-09 12:19:45,065 - __main__ - INFO - Typing prompt into textarea.
150
- 2025-06-09 12:19:45,465 - __main__ - INFO - Prompt submitted.
151
- 2025-06-09 12:19:45,466 - __main__ - INFO - Checking for 'Agree' button in dialog.
152
- 2025-06-09 12:19:45,559 - __main__ - INFO - 'Agree' button not visible, skipping.
153
- 2025-06-09 12:19:45,559 - __main__ - INFO - [98806519-9b36-4d7a-9c31-66529703a72f] Prompt sent. Streaming response...
154
- 2025-06-09 12:19:51,721 - streaming - INFO - [StreamProc/Process] Starting stream in Markdown conversion mode.
155
- 2025-06-09 12:20:05,631 - streaming - INFO - [StreamProc/PollStream] Content hasn't changed for 10.00s. Assuming stable.
156
- 2025-06-09 12:20:05,632 - __main__ - INFO - [98806519-9b36-4d7a-9c31-66529703a72f] Finished streaming response from browser.
157
- 2025-06-09 12:20:05,632 - __main__ - INFO - [98806519-9b36-4d7a-9c31-66529703a72f] Cleaning up chat session by clicking 'New Chat'.
158
- 2025-06-09 12:20:05,633 - __main__ - INFO - [98806519-9b36-4d7a-9c31-66529703a72f] Attempting to click 'New Chat' button.
159
- 2025-06-09 12:20:05,720 - __main__ - INFO - [98806519-9b36-4d7a-9c31-66529703a72f] 'New Chat' button clicked successfully.
160
- 2025-06-09 12:20:05,721 - streaming - INFO - [chatcmpl-1503f2e8146f468993892ee257265847] Yielding final chunk. Total content length: 356 chars.
161
- 2025-06-09 12:20:05,721 - streaming - INFO - [chatcmpl-1503f2e8146f468993892ee257265847] Yielding [DONE] signal.
162
- 2025-06-09 12:25:57,144 - __main__ - INFO - Application shutdown sequence initiated.
163
- 2025-06-09 12:25:57,145 - __main__ - INFO - Cleaning up and quitting Selenium driver...
164
- 2025-06-09 12:25:59,457 - __main__ - INFO - Driver quit successfully.
165
- 2025-06-09 12:25:59,458 - __main__ - INFO - Application shutdown sequence completed.
166
- 2025-06-09 12:26:36,462 - __main__ - INFO - Configuration loaded.
167
- 2025-06-09 12:26:36,472 - __main__ - INFO - DriverManager instance created.
168
- 2025-06-09 12:26:36,981 - __main__ - INFO - Gemini client initialized successfully.
169
- 2025-06-09 12:26:37,098 - __main__ - INFO - GEMINI_API_KEY is set.
170
- 2025-06-09 12:26:37,098 - __main__ - INFO - Starting Uvicorn server on 0.0.0.0:8000.
171
- 2025-06-09 12:26:37,172 - __main__ - INFO - Application startup sequence initiated.
172
- 2025-06-09 12:26:37,173 - __main__ - INFO - Initializing Selenium driver...
173
- 2025-06-09 12:26:37,175 - __main__ - INFO - Executing synchronous driver initialization and enhanced readiness check.
174
- 2025-06-09 12:26:41,365 - __main__ - INFO - Driver instantiated. Opening URL...
175
- 2025-06-09 12:26:46,688 - __main__ - INFO - URL 'https://beta.lmarena.ai/?mode=direct' opened.
176
- 2025-06-09 12:26:46,689 - __main__ - INFO - Attempting to solve initial (Cloudflare-style) captcha with uc_gui_click_captcha()...
177
- 2025-06-09 12:26:58,535 - __main__ - INFO - uc_gui_click_captcha() completed. Main site should be loading now.
178
- 2025-06-09 12:26:58,535 - __main__ - INFO - Checking for on-site ('Verify Human') captcha...
179
- 2025-06-09 12:27:08,679 - __main__ - INFO - No on-site captcha detected. Main UI is ready.
180
- 2025-06-09 12:27:08,680 - __main__ - INFO - Selenium driver initialization process completed successfully.
181
- 2025-06-09 12:27:08,680 - __main__ - INFO - Application startup sequence completed successfully.
182
- 2025-06-09 12:27:08,776 - __main__ - INFO - [chatcmpl-41dd7f08cfdf4fbe82c61425ad970193] Received chat completion request: model='qwen no think', stream=True, md_convert=True
183
- 2025-06-09 12:27:08,782 - streaming - INFO - [chatcmpl-41dd7f08cfdf4fbe82c61425ad970193] Starting streaming response generation for model 'qwen no think'.
184
- 2025-06-09 12:27:08,782 - __main__ - INFO - [9a7a0c77-671d-451c-8839-28f19cc10692] Starting chat. Model: 'qwen no think', RawHTML: False, MarkdownMode: True.
185
- 2025-06-09 12:27:08,783 - __main__ - INFO - Selecting model: qwen no think
186
- 2025-06-09 12:27:09,091 - __main__ - INFO - Selected model: qwen no think
187
- 2025-06-09 12:27:09,092 - __main__ - INFO - [9a7a0c77-671d-451c-8839-28f19cc10692] Sending prompt (first 50 chars): 'python pascals tree gen small concise code no comm...'
188
- 2025-06-09 12:27:09,092 - __main__ - INFO - Typing prompt into textarea.
189
- 2025-06-09 12:27:09,593 - __main__ - INFO - Prompt submitted.
190
- 2025-06-09 12:27:09,593 - __main__ - INFO - Checking for 'Agree' button in dialog.
191
- 2025-06-09 12:27:09,719 - __main__ - INFO - 'Agree' button not visible, skipping.
192
- 2025-06-09 12:27:09,719 - __main__ - INFO - [9a7a0c77-671d-451c-8839-28f19cc10692] Prompt sent. Streaming response...
193
- 2025-06-09 12:27:13,322 - streaming - INFO - [StreamProc/Process] Starting stream in Markdown conversion mode.
194
- 2025-06-09 12:27:29,116 - streaming - INFO - [StreamProc/PollStream] Content hasn't changed for 10.00s. Assuming stable.
195
- 2025-06-09 12:27:29,116 - __main__ - INFO - [9a7a0c77-671d-451c-8839-28f19cc10692] Finished streaming response from browser.
196
- 2025-06-09 12:27:29,117 - __main__ - INFO - [9a7a0c77-671d-451c-8839-28f19cc10692] Cleaning up chat session by clicking 'New Chat'.
197
- 2025-06-09 12:27:29,117 - __main__ - INFO - [9a7a0c77-671d-451c-8839-28f19cc10692] Attempting to click 'New Chat' button.
198
- 2025-06-09 12:27:29,217 - __main__ - INFO - [9a7a0c77-671d-451c-8839-28f19cc10692] 'New Chat' button clicked successfully.
199
- 2025-06-09 12:27:29,218 - streaming - INFO - [chatcmpl-41dd7f08cfdf4fbe82c61425ad970193] Yielding final chunk. Total content length: 354 chars.
200
- 2025-06-09 12:27:29,218 - streaming - INFO - [chatcmpl-41dd7f08cfdf4fbe82c61425ad970193] Yielding [DONE] signal.
201
- 2025-06-09 12:40:32,330 - __main__ - INFO - Application shutdown sequence initiated.
202
- 2025-06-09 12:40:32,331 - __main__ - INFO - Cleaning up and quitting Selenium driver...
203
- 2025-06-09 12:40:34,681 - __main__ - INFO - Driver quit successfully.
204
- 2025-06-09 12:40:34,681 - __main__ - INFO - Application shutdown sequence completed.
205
- 2025-06-09 12:40:42,096 - __main__ - INFO - Configuration loaded.
206
- 2025-06-09 12:40:42,104 - __main__ - INFO - DriverManager instance created.
207
- 2025-06-09 12:40:42,595 - __main__ - INFO - Gemini client initialized successfully.
208
- 2025-06-09 12:40:42,628 - __main__ - INFO - GEMINI_API_KEY is set.
209
- 2025-06-09 12:40:42,629 - __main__ - INFO - Starting Uvicorn server on 0.0.0.0:8000.
210
- 2025-06-09 12:40:42,654 - __main__ - INFO - Application startup sequence initiated.
211
- 2025-06-09 12:40:42,654 - __main__ - INFO - Initializing Selenium driver...
212
- 2025-06-09 12:40:42,656 - __main__ - INFO - Executing synchronous driver initialization and enhanced readiness check.
213
- 2025-06-09 12:40:45,740 - __main__ - INFO - Driver instantiated. Opening URL...
214
- 2025-06-09 12:40:51,056 - __main__ - INFO - URL 'https://beta.lmarena.ai/?mode=direct' opened.
215
- 2025-06-09 12:40:51,056 - __main__ - INFO - Attempting to solve initial (Cloudflare-style) captcha with uc_gui_click_captcha()...
216
- 2025-06-09 12:40:51,062 - __main__ - INFO - uc_gui_click_captcha() completed. Main site should be loading now.
217
- 2025-06-09 12:40:51,062 - __main__ - INFO - Checking for on-site ('Verify Human') captcha...
218
- 2025-06-09 12:41:03,731 - __main__ - INFO - No on-site captcha detected. Main UI is ready.
219
- 2025-06-09 12:41:03,732 - __main__ - INFO - Selenium driver initialization process completed successfully.
220
- 2025-06-09 12:41:03,732 - __main__ - INFO - Application startup sequence completed successfully.
221
- 2025-06-09 12:41:40,833 - __main__ - INFO - Configuration loaded.
222
- 2025-06-09 12:41:40,842 - __main__ - INFO - DriverManager instance created.
223
- 2025-06-09 12:41:41,356 - __main__ - INFO - Gemini client initialized successfully.
224
- 2025-06-09 12:41:41,389 - __main__ - INFO - GEMINI_API_KEY is set.
225
- 2025-06-09 12:41:41,390 - __main__ - INFO - Starting Uvicorn server on 0.0.0.0:8000.
226
- 2025-06-09 12:41:41,416 - __main__ - INFO - Application startup sequence initiated.
227
- 2025-06-09 12:41:41,417 - __main__ - INFO - Initializing Selenium driver...
228
- 2025-06-09 12:41:41,418 - __main__ - INFO - Executing synchronous driver initialization and enhanced readiness check.
229
- 2025-06-09 12:41:44,457 - __main__ - INFO - Driver instantiated. Opening URL...
230
- 2025-06-09 12:41:50,311 - __main__ - INFO - URL 'https://beta.lmarena.ai/?mode=direct' opened.
231
- 2025-06-09 12:41:50,311 - __main__ - INFO - Attempting to solve initial (Cloudflare-style) captcha with uc_gui_click_captcha()...
232
- 2025-06-09 12:41:50,724 - __main__ - INFO - uc_gui_click_captcha() completed. Main site should be loading now.
233
- 2025-06-09 12:41:50,725 - __main__ - INFO - Checking for on-site ('Verify Human') captcha...
234
- 2025-06-09 12:42:00,824 - __main__ - INFO - Textarea not ready or an on-site captcha indicator was found. Proceeding with AI solver.
235
- 2025-06-09 12:42:00,824 - __main__ - INFO - Starting visual AI check for on-site captcha.
236
- 2025-06-09 12:42:01,009 - __main__ - INFO - Sending screenshot to Gemini API for analysis.
237
- 2025-06-09 12:42:01,009 - google_genai.models - INFO - AFC is enabled with max remote calls: 10.
238
- 2025-06-09 12:42:01,010 - google_genai.models - INFO - AFC remote call 1 is done.
239
- 2025-06-09 12:42:03,591 - httpx - INFO - HTTP Request: POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:streamGenerateContent?alt=sse "HTTP/1.1 200 OK"
240
- 2025-06-09 12:42:03,744 - __main__ - INFO - Received Gemini response for on-site captcha check: ```json
241
- [
242
- {"box_2d": [721, 412, 755, 431], "label": "box"}
243
- ]
244
- ```
245
- 2025-06-09 12:42:03,744 - __main__ - INFO - On-site captcha checkbox found via Gemini. Clicking coordinates: {'box_2d': [721, 412, 755, 431], 'label': 'box'}
246
- 2025-06-09 12:42:07,526 - __main__ - INFO - Click performed. Now reloading page as requested for post-AI solve.
247
- 2025-06-09 12:42:07,527 - __main__ - INFO - Performing human-like page reload
248
- 2025-06-09 12:42:07,527 - __main__ - INFO - Using FN+F5 key combination
249
- 2025-06-09 12:42:09,853 - __main__ - INFO - Page reloaded after 1.42s delay
250
- 2025-06-09 12:42:14,855 - __main__ - INFO - Selenium driver initialization process completed successfully.
251
- 2025-06-09 12:42:14,856 - __main__ - INFO - Application startup sequence completed successfully.
252
- 2025-06-09 12:42:38,986 - __main__ - INFO - [chatcmpl-0e4becfc8b714621adc3a8e28fa6c832] Received chat completion request: model='Gemini 2.0 Flash', stream=True, md_convert=True
253
- 2025-06-09 12:42:38,992 - streaming - INFO - [chatcmpl-0e4becfc8b714621adc3a8e28fa6c832] Starting streaming response generation for model 'Gemini 2.0 Flash'.
254
- 2025-06-09 12:42:38,992 - __main__ - INFO - [65ec22f0-f7c9-4c84-97ea-9d279cd1a901] Starting chat. Model: 'Gemini 2.0 Flash', RawHTML: False, MarkdownMode: True.
255
- 2025-06-09 12:42:38,992 - __main__ - INFO - Selecting model: Gemini 2.0 Flash
256
- 2025-06-09 12:42:39,305 - __main__ - INFO - Selected model: Gemini 2.0 Flash
257
- 2025-06-09 12:42:39,306 - __main__ - INFO - [65ec22f0-f7c9-4c84-97ea-9d279cd1a901] Sending prompt (first 50 chars): 'python pascals tree gen small concise code no comm...'
258
- 2025-06-09 12:42:39,306 - __main__ - INFO - Typing prompt into textarea.
259
- 2025-06-09 12:42:39,815 - __main__ - INFO - Prompt submitted.
260
- 2025-06-09 12:42:39,815 - __main__ - INFO - Checking for 'Agree' button in dialog.
261
- 2025-06-09 12:42:39,917 - __main__ - INFO - 'Agree' button not visible, skipping.
262
- 2025-06-09 12:42:39,917 - __main__ - INFO - [65ec22f0-f7c9-4c84-97ea-9d279cd1a901] Prompt sent. Streaming response...
263
- 2025-06-09 12:42:52,374 - streaming - INFO - [StreamProc/PollStream] Content stable for 10.00s. Ending poll.
264
- 2025-06-09 12:42:52,378 - __main__ - INFO - [65ec22f0-f7c9-4c84-97ea-9d279cd1a901] Finished streaming response from browser.
265
- 2025-06-09 12:42:52,378 - __main__ - INFO - [65ec22f0-f7c9-4c84-97ea-9d279cd1a901] Cleaning up chat session by clicking 'New Chat'.
266
- 2025-06-09 12:42:52,378 - __main__ - INFO - [65ec22f0-f7c9-4c84-97ea-9d279cd1a901] Attempting to click 'New Chat' button.
267
- 2025-06-09 12:42:52,462 - __main__ - INFO - [65ec22f0-f7c9-4c84-97ea-9d279cd1a901] 'New Chat' button clicked successfully.
268
- 2025-06-09 12:42:52,463 - streaming - INFO - [chatcmpl-0e4becfc8b714621adc3a8e28fa6c832] Yielding final chunk. Total content length: 147 chars.
269
- 2025-06-09 12:42:52,463 - streaming - INFO - [chatcmpl-0e4becfc8b714621adc3a8e28fa6c832] Yielding [DONE] signal.
270
- 2025-06-09 12:43:26,774 - __main__ - INFO - [chatcmpl-3e2d2d8cded1427495834f07c4c5758b] Received chat completion request: model='Qwen No Think', stream=True, md_convert=True
271
- 2025-06-09 12:43:26,775 - streaming - INFO - [chatcmpl-3e2d2d8cded1427495834f07c4c5758b] Starting streaming response generation for model 'Qwen No Think'.
272
- 2025-06-09 12:43:26,775 - __main__ - INFO - [2ea7dfd7-36df-44f6-b3c7-5b3b8e4c10b3] Starting chat. Model: 'Qwen No Think', RawHTML: False, MarkdownMode: True.
273
- 2025-06-09 12:43:26,776 - __main__ - INFO - Selecting model: Qwen No Think
274
- 2025-06-09 12:43:27,035 - __main__ - INFO - Selected model: Qwen No Think
275
- 2025-06-09 12:43:27,036 - __main__ - INFO - [2ea7dfd7-36df-44f6-b3c7-5b3b8e4c10b3] Sending prompt (first 50 chars): 'python pascals tree gen long code no comments...'
276
- 2025-06-09 12:43:27,036 - __main__ - INFO - Typing prompt into textarea.
277
- 2025-06-09 12:43:27,342 - __main__ - INFO - Prompt submitted.
278
- 2025-06-09 12:43:27,342 - __main__ - INFO - Checking for 'Agree' button in dialog.
279
- 2025-06-09 12:43:28,373 - __main__ - INFO - 'Agree' button not visible, skipping.
280
- 2025-06-09 12:43:28,374 - __main__ - INFO - [2ea7dfd7-36df-44f6-b3c7-5b3b8e4c10b3] Prompt sent. Streaming response...
281
- 2025-06-09 12:43:48,331 - streaming - INFO - [StreamProc/PollStream] Content stable for 10.00s. Ending poll.
282
- 2025-06-09 12:43:48,343 - __main__ - INFO - [2ea7dfd7-36df-44f6-b3c7-5b3b8e4c10b3] Finished streaming response from browser.
283
- 2025-06-09 12:43:48,343 - __main__ - INFO - [2ea7dfd7-36df-44f6-b3c7-5b3b8e4c10b3] Cleaning up chat session by clicking 'New Chat'.
284
- 2025-06-09 12:43:48,343 - __main__ - INFO - [2ea7dfd7-36df-44f6-b3c7-5b3b8e4c10b3] Attempting to click 'New Chat' button.
285
- 2025-06-09 12:43:48,425 - __main__ - INFO - [2ea7dfd7-36df-44f6-b3c7-5b3b8e4c10b3] 'New Chat' button clicked successfully.
286
- 2025-06-09 12:43:48,425 - streaming - INFO - [chatcmpl-3e2d2d8cded1427495834f07c4c5758b] Yielding final chunk. Total content length: 1323 chars.
287
- 2025-06-09 12:43:48,425 - streaming - INFO - [chatcmpl-3e2d2d8cded1427495834f07c4c5758b] Yielding [DONE] signal.
288
- 2025-06-09 12:45:57,240 - __main__ - INFO - Configuration loaded.
289
- 2025-06-09 12:45:57,248 - __main__ - INFO - DriverManager instance created.
290
- 2025-06-09 12:45:57,740 - __main__ - INFO - Gemini client initialized successfully.
291
- 2025-06-09 12:45:57,774 - __main__ - INFO - GEMINI_API_KEY is set.
292
- 2025-06-09 12:45:57,774 - __main__ - INFO - Starting Uvicorn server on 0.0.0.0:8000.
293
- 2025-06-09 12:45:57,799 - __main__ - INFO - Application startup sequence initiated.
294
- 2025-06-09 12:45:57,799 - __main__ - INFO - Initializing Selenium driver...
295
- 2025-06-09 12:45:57,801 - __main__ - INFO - Executing synchronous driver initialization and enhanced readiness check.
296
- 2025-06-09 12:46:00,849 - __main__ - INFO - Driver instantiated. Opening URL...
297
- 2025-06-09 12:46:07,223 - __main__ - INFO - URL 'https://beta.lmarena.ai/?mode=direct' opened.
298
- 2025-06-09 12:46:07,223 - __main__ - INFO - Attempting to solve initial (Cloudflare-style) captcha with uc_gui_click_captcha()...
299
- 2025-06-09 12:46:07,632 - __main__ - INFO - uc_gui_click_captcha() completed. Main site should be loading now.
300
- 2025-06-09 12:46:07,632 - __main__ - INFO - Checking for on-site ('Verify Human') captcha...
301
- 2025-06-09 12:46:17,736 - __main__ - INFO - Textarea not ready or an on-site captcha indicator was found. Proceeding with AI solver.
302
- 2025-06-09 12:46:17,736 - __main__ - INFO - Starting visual AI check for on-site captcha.
303
- 2025-06-09 12:46:17,898 - __main__ - INFO - Sending screenshot to Gemini API for analysis.
304
- 2025-06-09 12:46:17,899 - google_genai.models - INFO - AFC is enabled with max remote calls: 10.
305
- 2025-06-09 12:46:17,899 - google_genai.models - INFO - AFC remote call 1 is done.
306
- 2025-06-09 12:46:20,718 - httpx - INFO - HTTP Request: POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:streamGenerateContent?alt=sse "HTTP/1.1 200 OK"
307
- 2025-06-09 12:46:20,809 - __main__ - INFO - Received Gemini response for on-site captcha check: ```json
308
- [
309
- {"box_2d": [728, 414, 747, 426], "label": "box"}
310
- ]
311
- ```
312
- 2025-06-09 12:46:20,809 - __main__ - INFO - On-site captcha checkbox found via Gemini. Clicking coordinates: {'box_2d': [728, 414, 747, 426], 'label': 'box'}
313
- 2025-06-09 12:46:24,589 - __main__ - INFO - Click performed. Now reloading page as requested for post-AI solve.
314
- 2025-06-09 12:46:24,590 - __main__ - INFO - Performing human-like page reload
315
- 2025-06-09 12:46:24,591 - __main__ - INFO - Using FN+F5 key combination
316
- 2025-06-09 12:46:26,398 - __main__ - INFO - Page reloaded after 0.90s delay
317
- 2025-06-09 12:46:31,400 - __main__ - INFO - Selenium driver initialization process completed successfully.
318
- 2025-06-09 12:46:31,401 - __main__ - INFO - Application startup sequence completed successfully.
319
- 2025-06-09 12:46:39,072 - __main__ - INFO - [chatcmpl-61168434d655486299ab964cfa879aaa] Received chat completion request: model='Qwen No Think', stream=True, md_convert=True
320
- 2025-06-09 12:46:39,078 - streaming - INFO - [chatcmpl-61168434d655486299ab964cfa879aaa] Starting streaming response generation for model 'Qwen No Think'.
321
- 2025-06-09 12:46:39,079 - __main__ - INFO - [876f2d65-bd15-445f-bf51-12d77336ca0c] Starting chat. Model: 'Qwen No Think', RawHTML: False, MarkdownMode: True.
322
- 2025-06-09 12:46:39,079 - __main__ - INFO - Selecting model: Qwen No Think
323
- 2025-06-09 12:46:39,440 - __main__ - INFO - Selected model: Qwen No Think
324
- 2025-06-09 12:46:39,441 - __main__ - INFO - [876f2d65-bd15-445f-bf51-12d77336ca0c] Sending prompt (first 50 chars): 'python pascals tree gen long code no comments...'
325
- 2025-06-09 12:46:39,441 - __main__ - INFO - Typing prompt into textarea.
326
- 2025-06-09 12:46:39,832 - __main__ - INFO - Prompt submitted.
327
- 2025-06-09 12:46:39,833 - __main__ - INFO - Checking for 'Agree' button in dialog.
328
- 2025-06-09 12:46:39,925 - __main__ - INFO - 'Agree' button not visible, skipping.
329
- 2025-06-09 12:46:39,926 - __main__ - INFO - [876f2d65-bd15-445f-bf51-12d77336ca0c] Prompt sent. Streaming response...
330
- 2025-06-09 12:46:43,010 - __main__ - ERROR - Streaming error: StreamConfig.__init__() got an unexpected keyword argument 'stream_raw_html'
331
- Traceback (most recent call last):
332
- File "c:\Users\caree\Code\Lmarena\api.py", line 414, in _stream_response
333
- stream_config = StreamConfig(
334
- poll_interval=config.poll_interval,
335
- ...<4 lines>...
336
- convert_html_to_markdown=convert_html_to_markdown
337
- )
338
- TypeError: StreamConfig.__init__() got an unexpected keyword argument 'stream_raw_html'
339
- 2025-06-09 12:46:43,012 - __main__ - INFO - [876f2d65-bd15-445f-bf51-12d77336ca0c] Finished streaming response from browser.
340
- 2025-06-09 12:46:43,012 - __main__ - INFO - [876f2d65-bd15-445f-bf51-12d77336ca0c] Cleaning up chat session by clicking 'New Chat'.
341
- 2025-06-09 12:46:43,012 - __main__ - INFO - [876f2d65-bd15-445f-bf51-12d77336ca0c] Attempting to click 'New Chat' button.
342
- 2025-06-09 12:46:43,117 - __main__ - INFO - [876f2d65-bd15-445f-bf51-12d77336ca0c] 'New Chat' button clicked successfully.
343
- 2025-06-09 13:13:16,829 - __main__ - INFO - Application shutdown sequence initiated.
344
- 2025-06-09 13:13:16,830 - __main__ - INFO - Cleaning up and quitting Selenium driver...
345
- 2025-06-09 13:13:19,250 - __main__ - INFO - Driver quit successfully.
346
- 2025-06-09 13:13:19,251 - __main__ - INFO - Application shutdown sequence completed.
347
- 2025-06-09 13:13:22,817 - __main__ - INFO - Configuration loaded.
348
- 2025-06-09 13:13:22,825 - __main__ - INFO - DriverManager instance created.
349
- 2025-06-09 13:13:23,338 - __main__ - INFO - Gemini client initialized successfully.
350
- 2025-06-09 13:13:23,372 - __main__ - INFO - GEMINI_API_KEY is set.
351
- 2025-06-09 13:13:23,372 - __main__ - INFO - Starting Uvicorn server on 0.0.0.0:8000.
352
- 2025-06-09 13:13:23,398 - __main__ - INFO - Application startup sequence initiated.
353
- 2025-06-09 13:13:23,399 - __main__ - INFO - Initializing Selenium driver...
354
- 2025-06-09 13:13:23,400 - __main__ - INFO - Executing synchronous driver initialization and enhanced readiness check.
355
- 2025-06-09 13:13:26,459 - __main__ - INFO - Driver instantiated. Opening URL...
356
- 2025-06-09 13:13:31,687 - __main__ - INFO - URL 'https://beta.lmarena.ai/?mode=direct' opened.
357
- 2025-06-09 13:13:31,687 - __main__ - INFO - Attempting to solve initial (Cloudflare-style) captcha with uc_gui_click_captcha()...
358
- 2025-06-09 13:13:42,971 - __main__ - INFO - uc_gui_click_captcha() completed. Main site should be loading now.
359
- 2025-06-09 13:13:42,971 - __main__ - INFO - Checking for on-site ('Verify Human') captcha...
360
- 2025-06-09 13:13:53,072 - __main__ - INFO - No on-site captcha detected. Main UI is ready.
361
- 2025-06-09 13:13:53,073 - __main__ - INFO - Selenium driver initialization process completed successfully.
362
- 2025-06-09 13:13:53,073 - __main__ - INFO - Application startup sequence completed successfully.
363
- 2025-06-09 13:14:00,232 - __main__ - INFO - [chatcmpl-a016b7ca118c4d9b94482a2fc53638ca] Received chat completion request: model='Qwen No Think', stream=True, md_convert=True
364
- 2025-06-09 13:14:00,238 - streaming - INFO - [chatcmpl-a016b7ca118c4d9b94482a2fc53638ca] Starting streaming response generation for model 'Qwen No Think'.
365
- 2025-06-09 13:14:00,238 - __main__ - INFO - [0e1927b9-8699-4b08-9338-c2962ebdc6d9] Starting chat. Model: 'Qwen No Think', RawHTML: False, MarkdownMode: True.
366
- 2025-06-09 13:14:00,239 - __main__ - INFO - Selecting model: Qwen No Think
367
- 2025-06-09 13:14:00,505 - __main__ - INFO - Selected model: Qwen No Think
368
- 2025-06-09 13:14:00,506 - __main__ - INFO - [0e1927b9-8699-4b08-9338-c2962ebdc6d9] Sending prompt (first 50 chars): 'python pascals tree gen long code no comments...'
369
- 2025-06-09 13:14:00,506 - __main__ - INFO - Typing prompt into textarea.
370
- 2025-06-09 13:14:00,862 - __main__ - INFO - Prompt submitted.
371
- 2025-06-09 13:14:00,862 - __main__ - INFO - Checking for 'Agree' button in dialog.
372
- 2025-06-09 13:14:01,106 - __main__ - INFO - 'Agree' button not visible, skipping.
373
- 2025-06-09 13:14:01,106 - __main__ - INFO - [0e1927b9-8699-4b08-9338-c2962ebdc6d9] Prompt sent. Streaming response...
374
- 2025-06-09 13:17:05,718 - streaming - ERROR - [StreamProc/PollStream] Unexpected error polling: Message: no such window: target window already closed
375
- from unknown error: web view not found
376
- (Session info: chrome=137.0.7151.69)
377
- Stacktrace:
378
- GetHandleVerifier [0x0x7ff748e66f65+78965]
379
- GetHandleVerifier [0x0x7ff748e66fc0+79056]
380
- (No symbol) [0x0x7ff748bf9dda]
381
- (No symbol) [0x0x7ff748bd20d1]
382
- (No symbol) [0x0x7ff748c7ff4e]
383
- (No symbol) [0x0x7ff748ca06cd]
384
- (No symbol) [0x0x7ff748c78443]
385
- (No symbol) [0x0x7ff748c41311]
386
- (No symbol) [0x0x7ff748c420a3]
387
- GetHandleVerifier [0x0x7ff74911e26d+2926461]
388
- GetHandleVerifier [0x0x7ff749118993+2903715]
389
- GetHandleVerifier [0x0x7ff749136aed+3026941]
390
- GetHandleVerifier [0x0x7ff748e816fe+187406]
391
- GetHandleVerifier [0x0x7ff748e896ef+220159]
392
- GetHandleVerifier [0x0x7ff748e6faf4+114692]
393
- GetHandleVerifier [0x0x7ff748e6fca9+115129]
394
- GetHandleVerifier [0x0x7ff748e564d8+10728]
395
- BaseThreadInitThunk [0x0x7ffd6f06e8d7+23]
396
- RtlUserThreadStart [0x0x7ffd6fafc5dc+44]
397
- Traceback (most recent call last):
398
- File "c:\Users\caree\Code\Lmarena\streaming.py", line 190, in _poll_element_content_stream
399
- # Convert all finalized elements to markdown
400
- File "C:\Users\caree\AppData\Local\Programs\Python\Python313\Lib\site-packages\selenium\webdriver\support\wait.py", line 129, in until
401
- value = method(self._driver)
402
- File "C:\Users\caree\AppData\Local\Programs\Python\Python313\Lib\site-packages\selenium\webdriver\support\expected_conditions.py", line 104, in _predicate
403
- return driver.find_element(*locator)
404
- ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
405
- File "C:\Users\caree\AppData\Local\Programs\Python\Python313\Lib\site-packages\seleniumbase\core\sb_driver.py", line 27, in find_element
406
- return self.driver.default_find_element(by=by, value=value)
407
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
408
- File "C:\Users\caree\AppData\Local\Programs\Python\Python313\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 914, in find_element
409
- return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
410
- ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
411
- File "C:\Users\caree\AppData\Local\Programs\Python\Python313\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 447, in execute
412
- self.error_handler.check_response(response)
413
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
414
- File "C:\Users\caree\AppData\Local\Programs\Python\Python313\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 232, in check_response
415
- raise exception_class(message, screen, stacktrace)
416
- selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
417
- from unknown error: web view not found
418
- (Session info: chrome=137.0.7151.69)
419
- Stacktrace:
420
- GetHandleVerifier [0x0x7ff748e66f65+78965]
421
- GetHandleVerifier [0x0x7ff748e66fc0+79056]
422
- (No symbol) [0x0x7ff748bf9dda]
423
- (No symbol) [0x0x7ff748bd20d1]
424
- (No symbol) [0x0x7ff748c7ff4e]
425
- (No symbol) [0x0x7ff748ca06cd]
426
- (No symbol) [0x0x7ff748c78443]
427
- (No symbol) [0x0x7ff748c41311]
428
- (No symbol) [0x0x7ff748c420a3]
429
- GetHandleVerifier [0x0x7ff74911e26d+2926461]
430
- GetHandleVerifier [0x0x7ff749118993+2903715]
431
- GetHandleVerifier [0x0x7ff749136aed+3026941]
432
- GetHandleVerifier [0x0x7ff748e816fe+187406]
433
- GetHandleVerifier [0x0x7ff748e896ef+220159]
434
- GetHandleVerifier [0x0x7ff748e6faf4+114692]
435
- GetHandleVerifier [0x0x7ff748e6fca9+115129]
436
- GetHandleVerifier [0x0x7ff748e564d8+10728]
437
- BaseThreadInitThunk [0x0x7ffd6f06e8d7+23]
438
- RtlUserThreadStart [0x0x7ffd6fafc5dc+44]
439
-
440
- 2025-06-09 13:17:05,797 - __main__ - INFO - [0e1927b9-8699-4b08-9338-c2962ebdc6d9] Finished streaming response from browser.
441
- 2025-06-09 13:17:05,797 - __main__ - INFO - [0e1927b9-8699-4b08-9338-c2962ebdc6d9] Cleaning up chat session by clicking 'New Chat'.
442
- 2025-06-09 13:17:05,798 - __main__ - INFO - [0e1927b9-8699-4b08-9338-c2962ebdc6d9] Attempting to click 'New Chat' button.
443
- 2025-06-09 13:17:12,857 - __main__ - ERROR - [0e1927b9-8699-4b08-9338-c2962ebdc6d9] Error clicking 'New Chat' during cleanup: Message:
444
- Element {//a[contains(@class, 'whitespace-nowrap') and .//h2[contains(text(), 'New Chat')]]} was not present after 7 seconds!
445
- Traceback (most recent call last):
446
- File "c:\Users\caree\Code\Lmarena\api.py", line 384, in send_message_and_stream_response
447
- await ChatHandler._click_new_chat(driver, request_id)
448
- File "c:\Users\caree\Code\Lmarena\api.py", line 442, in _click_new_chat
449
- yield item
450
- File "C:\Users\caree\AppData\Local\Programs\Python\Python313\Lib\concurrent\futures\thread.py", line 59, in run
451
- result = self.fn(*self.args, **self.kwargs)
452
- File "c:\Users\caree\Code\Lmarena\api.py", line 442, in <lambda>
453
- yield item
454
-
455
- File "C:\Users\caree\AppData\Local\Programs\Python\Python313\Lib\site-packages\seleniumbase\core\sb_driver.py", line 82, in click
456
- page_actions.click(self.driver, *args, **kwargs)
457
- ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
458
- File "C:\Users\caree\AppData\Local\Programs\Python\Python313\Lib\site-packages\seleniumbase\fixtures\page_actions.py", line 1595, in click
459
- element = wait_for_element_clickable(
460
- driver, selector, by=by, timeout=timeout
461
- )
462
- File "C:\Users\caree\AppData\Local\Programs\Python\Python313\Lib\site-packages\seleniumbase\fixtures\page_actions.py", line 910, in wait_for_element_clickable
463
- timeout_exception(NoSuchElementException, message)
464
- ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
465
- File "C:\Users\caree\AppData\Local\Programs\Python\Python313\Lib\site-packages\seleniumbase\fixtures\page_actions.py", line 267, in timeout_exception
466
- raise exc(msg)
467
- seleniumbase.common.exceptions.NoSuchElementException: Message:
468
- Element {//a[contains(@class, 'whitespace-nowrap') and .//h2[contains(text(), 'New Chat')]]} was not present after 7 seconds!
469
-
470
- 2025-06-09 13:17:16,355 - __main__ - INFO - Configuration loaded.
471
- 2025-06-09 13:17:16,363 - __main__ - INFO - DriverManager instance created.
472
- 2025-06-09 13:17:16,867 - __main__ - INFO - Gemini client initialized successfully.
473
- 2025-06-09 13:17:16,902 - __main__ - INFO - GEMINI_API_KEY is set.
474
- 2025-06-09 13:17:16,902 - __main__ - INFO - Starting Uvicorn server on 0.0.0.0:8000.
475
- 2025-06-09 13:17:16,929 - __main__ - INFO - Application startup sequence initiated.
476
- 2025-06-09 13:17:16,930 - __main__ - INFO - Initializing Selenium driver...
477
- 2025-06-09 13:17:16,931 - __main__ - INFO - Executing synchronous driver initialization and enhanced readiness check.
478
- 2025-06-09 13:17:19,968 - __main__ - INFO - Driver instantiated. Opening URL...
479
- 2025-06-09 13:17:25,172 - __main__ - INFO - URL 'https://beta.lmarena.ai/?mode=direct' opened.
480
- 2025-06-09 13:17:25,172 - __main__ - INFO - Attempting to solve initial (Cloudflare-style) captcha with uc_gui_click_captcha()...
481
- 2025-06-09 13:17:36,533 - __main__ - INFO - uc_gui_click_captcha() completed. Main site should be loading now.
482
- 2025-06-09 13:17:36,534 - __main__ - INFO - Checking for on-site ('Verify Human') captcha...
483
- 2025-06-09 13:17:46,626 - __main__ - INFO - No on-site captcha detected. Main UI is ready.
484
- 2025-06-09 13:17:46,627 - __main__ - INFO - Selenium driver initialization process completed successfully.
485
- 2025-06-09 13:17:46,627 - __main__ - INFO - Application startup sequence completed successfully.
486
- 2025-06-09 13:17:47,719 - __main__ - INFO - [chatcmpl-dad296131df54a5d9fc92ff2820fc08f] Received chat completion request: model='Qwen No Think', stream=True, md_convert=True
487
- 2025-06-09 13:17:47,725 - streaming - INFO - [chatcmpl-dad296131df54a5d9fc92ff2820fc08f] Starting streaming response generation for model 'Qwen No Think'.
488
- 2025-06-09 13:17:47,725 - __main__ - INFO - [8382e611-556c-4cc7-a67a-2efc5d9f5ad3] Starting chat. Model: 'Qwen No Think', RawHTML: False, MarkdownMode: True.
489
- 2025-06-09 13:17:47,725 - __main__ - INFO - Selecting model: Qwen No Think
490
- 2025-06-09 13:17:48,003 - __main__ - INFO - Selected model: Qwen No Think
491
- 2025-06-09 13:17:48,004 - __main__ - INFO - [8382e611-556c-4cc7-a67a-2efc5d9f5ad3] Sending prompt (first 50 chars): 'python pascals tree gen long code no comments...'
492
- 2025-06-09 13:17:48,004 - __main__ - INFO - Typing prompt into textarea.
493
- 2025-06-09 13:17:48,357 - __main__ - INFO - Prompt submitted.
494
- 2025-06-09 13:17:48,357 - __main__ - INFO - Checking for 'Agree' button in dialog.
495
- 2025-06-09 13:17:48,587 - __main__ - INFO - 'Agree' button not visible, skipping.
496
- 2025-06-09 13:17:48,588 - __main__ - INFO - [8382e611-556c-4cc7-a67a-2efc5d9f5ad3] Prompt sent. Streaming response...
497
- 2025-06-09 13:18:11,478 - streaming - INFO - [StreamProc/PollStream] Content stable for 10.00s. Ending poll.
498
- 2025-06-09 13:18:11,489 - __main__ - INFO - [8382e611-556c-4cc7-a67a-2efc5d9f5ad3] Finished streaming response from browser.
499
- 2025-06-09 13:18:11,489 - __main__ - INFO - [8382e611-556c-4cc7-a67a-2efc5d9f5ad3] Cleaning up chat session by clicking 'New Chat'.
500
- 2025-06-09 13:18:11,490 - __main__ - INFO - [8382e611-556c-4cc7-a67a-2efc5d9f5ad3] Attempting to click 'New Chat' button.
501
- 2025-06-09 13:18:11,577 - __main__ - INFO - [8382e611-556c-4cc7-a67a-2efc5d9f5ad3] 'New Chat' button clicked successfully.
502
- 2025-06-09 13:18:11,578 - streaming - INFO - [chatcmpl-dad296131df54a5d9fc92ff2820fc08f] Yielding final chunk. Total content length: 1566 chars.
503
- 2025-06-09 13:18:11,578 - streaming - INFO - [chatcmpl-dad296131df54a5d9fc92ff2820fc08f] Yielding [DONE] signal.
504
- 2025-06-09 13:21:08,343 - __main__ - INFO - Configuration loaded.
505
- 2025-06-09 13:21:08,351 - __main__ - INFO - DriverManager instance created.
506
- 2025-06-09 13:21:08,842 - __main__ - INFO - Gemini client initialized successfully.
507
- 2025-06-09 13:21:08,875 - __main__ - INFO - GEMINI_API_KEY is set.
508
- 2025-06-09 13:21:08,876 - __main__ - INFO - Starting Uvicorn server on 0.0.0.0:8000.
509
- 2025-06-09 13:21:08,902 - __main__ - INFO - Application startup sequence initiated.
510
- 2025-06-09 13:21:08,902 - __main__ - INFO - Initializing Selenium driver...
511
- 2025-06-09 13:21:08,904 - __main__ - INFO - Executing synchronous driver initialization and enhanced readiness check.
512
- 2025-06-09 13:21:11,994 - __main__ - INFO - Driver instantiated. Opening URL...
513
- 2025-06-09 13:21:17,315 - __main__ - INFO - URL 'https://beta.lmarena.ai/?mode=direct' opened.
514
- 2025-06-09 13:21:17,316 - __main__ - INFO - Attempting to solve initial (Cloudflare-style) captcha with uc_gui_click_captcha()...
515
- 2025-06-09 13:21:17,324 - __main__ - INFO - uc_gui_click_captcha() completed. Main site should be loading now.
516
- 2025-06-09 13:21:17,325 - __main__ - INFO - Checking for on-site ('Verify Human') captcha...
517
- 2025-06-09 13:21:22,605 - __main__ - INFO - Chat input textarea not interactable. Proceeding with AI captcha solver.
518
- 2025-06-09 13:21:22,605 - __main__ - INFO - Starting visual AI check for on-site captcha.
519
- 2025-06-09 13:21:22,740 - __main__ - INFO - Sending screenshot to Gemini API for analysis.
520
- 2025-06-09 13:21:22,740 - google_genai.models - INFO - AFC is enabled with max remote calls: 10.
521
- 2025-06-09 13:21:22,741 - google_genai.models - INFO - AFC remote call 1 is done.
522
- 2025-06-09 13:21:25,207 - httpx - INFO - HTTP Request: POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:streamGenerateContent?alt=sse "HTTP/1.1 200 OK"
523
- 2025-06-09 13:21:25,465 - __main__ - INFO - Received Gemini response for on-site captcha check: ```json
524
- [
525
- {"box_2d": [578, 164, 614, 186], "label": "box"}
526
- ]
527
- ```
528
- 2025-06-09 13:21:25,466 - __main__ - INFO - On-site captcha checkbox found via Gemini. Clicking coordinates: {'box_2d': [578, 164, 614, 186], 'label': 'box'}
529
- 2025-06-09 13:21:29,140 - __main__ - INFO - Click performed. Now reloading page as requested for post-AI solve.
530
- 2025-06-09 13:21:29,140 - __main__ - INFO - Performing human-like page reload
531
- 2025-06-09 13:21:29,141 - __main__ - INFO - Using FN+F5 key combination
532
- 2025-06-09 13:21:30,930 - __main__ - INFO - Page reloaded after 0.88s delay
533
- 2025-06-09 13:21:35,931 - __main__ - INFO - Selenium driver initialization process completed successfully.
534
- 2025-06-09 13:21:35,931 - __main__ - INFO - Application startup sequence completed successfully.
535
- 2025-06-09 13:21:49,966 - __main__ - INFO - [chatcmpl-d6223c77e0534551872ec565df4666fa] Received chat completion request: model='Qwen No Think', stream=True, md_convert=True
536
- 2025-06-09 13:21:49,972 - streaming - INFO - [chatcmpl-d6223c77e0534551872ec565df4666fa] Starting streaming response generation for model 'Qwen No Think'.
537
- 2025-06-09 13:21:49,972 - __main__ - INFO - [ffe50244-a76d-4a41-b938-5f943206d84f] Starting chat. Model: 'Qwen No Think', RawHTML: False, MarkdownMode: True.
538
- 2025-06-09 13:21:49,972 - __main__ - INFO - Selecting model: Qwen No Think
539
- 2025-06-09 13:21:50,279 - __main__ - INFO - Selected model: Qwen No Think
540
- 2025-06-09 13:21:50,279 - __main__ - INFO - [ffe50244-a76d-4a41-b938-5f943206d84f] Sending prompt (first 50 chars): 'python pascals tree gen long code no comments...'
541
- 2025-06-09 13:21:50,280 - __main__ - INFO - Typing prompt into textarea.
542
- 2025-06-09 13:21:50,640 - __main__ - INFO - Prompt submitted.
543
- 2025-06-09 13:21:50,641 - __main__ - INFO - Checking for 'Agree' button in dialog.
544
- 2025-06-09 13:21:50,772 - __main__ - INFO - 'Agree' button not visible, skipping.
545
- 2025-06-09 13:21:50,772 - __main__ - INFO - [ffe50244-a76d-4a41-b938-5f943206d84f] Prompt sent. Streaming response...
546
- 2025-06-09 13:22:11,608 - streaming - INFO - [StreamProc/PollStream] Content stable for 10.00s. Ending poll.
547
- 2025-06-09 13:22:11,616 - __main__ - INFO - [ffe50244-a76d-4a41-b938-5f943206d84f] Finished streaming response from browser.
548
- 2025-06-09 13:22:11,616 - __main__ - INFO - [ffe50244-a76d-4a41-b938-5f943206d84f] Cleaning up chat session by clicking 'New Chat'.
549
- 2025-06-09 13:22:11,617 - __main__ - INFO - [ffe50244-a76d-4a41-b938-5f943206d84f] Attempting to click 'New Chat' button.
550
- 2025-06-09 13:22:11,701 - __main__ - INFO - [ffe50244-a76d-4a41-b938-5f943206d84f] 'New Chat' button clicked successfully.
551
- 2025-06-09 13:22:11,701 - streaming - INFO - [chatcmpl-d6223c77e0534551872ec565df4666fa] Yielding final chunk. Total content length: 1249 chars.
552
- 2025-06-09 13:22:11,701 - streaming - INFO - [chatcmpl-d6223c77e0534551872ec565df4666fa] Yielding [DONE] signal.
553
- 2025-06-09 13:22:51,763 - __main__ - INFO - [chatcmpl-906b9b8c6d38464f8416cf58c56947bc] Received chat completion request: model='Claude Opus 4 Thinking', stream=True, md_convert=True
554
- 2025-06-09 13:22:51,764 - streaming - INFO - [chatcmpl-906b9b8c6d38464f8416cf58c56947bc] Starting streaming response generation for model 'Claude Opus 4 Thinking'.
555
- 2025-06-09 13:22:51,765 - __main__ - INFO - [b9ae0a31-1028-443b-a3dc-aa74a12fedef] Starting chat. Model: 'Claude Opus 4 Thinking', RawHTML: False, MarkdownMode: True.
556
- 2025-06-09 13:22:51,765 - __main__ - INFO - Selecting model: Claude Opus 4 Thinking
557
- 2025-06-09 13:22:52,143 - __main__ - INFO - Selected model: Claude Opus 4 Thinking
558
- 2025-06-09 13:22:52,143 - __main__ - INFO - [b9ae0a31-1028-443b-a3dc-aa74a12fedef] Sending prompt (first 50 chars): 'python pascals tree gen long code no comments...'
559
- 2025-06-09 13:22:52,144 - __main__ - INFO - Typing prompt into textarea.
560
- 2025-06-09 13:22:52,487 - __main__ - INFO - Prompt submitted.
561
- 2025-06-09 13:22:52,487 - __main__ - INFO - Checking for 'Agree' button in dialog.
562
- 2025-06-09 13:22:53,513 - __main__ - INFO - 'Agree' button not visible, skipping.
563
- 2025-06-09 13:22:53,513 - __main__ - INFO - [b9ae0a31-1028-443b-a3dc-aa74a12fedef] Prompt sent. Streaming response...
564
- 2025-06-09 13:24:08,306 - streaming - INFO - [StreamProc/PollStream] Content stable for 10.00s. Ending poll.
565
- 2025-06-09 13:24:08,404 - __main__ - INFO - [b9ae0a31-1028-443b-a3dc-aa74a12fedef] Finished streaming response from browser.
566
- 2025-06-09 13:24:08,404 - __main__ - INFO - [b9ae0a31-1028-443b-a3dc-aa74a12fedef] Cleaning up chat session by clicking 'New Chat'.
567
- 2025-06-09 13:24:08,404 - __main__ - INFO - [b9ae0a31-1028-443b-a3dc-aa74a12fedef] Attempting to click 'New Chat' button.
568
- 2025-06-09 13:24:09,131 - __main__ - INFO - [b9ae0a31-1028-443b-a3dc-aa74a12fedef] 'New Chat' button clicked successfully.
569
- 2025-06-09 13:24:09,132 - streaming - INFO - [chatcmpl-906b9b8c6d38464f8416cf58c56947bc] Yielding final chunk. Total content length: 12889 chars.
570
- 2025-06-09 13:24:09,132 - streaming - INFO - [chatcmpl-906b9b8c6d38464f8416cf58c56947bc] Yielding [DONE] signal.
571
- 2025-06-09 13:24:37,914 - __main__ - INFO - [chatcmpl-8397b786dfc94d6fa186bf302fdb5091] Received chat completion request: model='Claude Opus 4 Thinking', stream=True, md_convert=True
572
- 2025-06-09 13:24:37,915 - streaming - INFO - [chatcmpl-8397b786dfc94d6fa186bf302fdb5091] Starting streaming response generation for model 'Claude Opus 4 Thinking'.
573
- 2025-06-09 13:24:37,916 - __main__ - INFO - [ddd1b72b-d54f-46d0-a3c9-32760b378dce] Starting chat. Model: 'Claude Opus 4 Thinking', RawHTML: False, MarkdownMode: True.
574
- 2025-06-09 13:24:37,916 - __main__ - INFO - Selecting model: Claude Opus 4 Thinking
575
- 2025-06-09 13:24:38,290 - __main__ - INFO - Selected model: Claude Opus 4 Thinking
576
- 2025-06-09 13:24:38,291 - __main__ - INFO - [ddd1b72b-d54f-46d0-a3c9-32760b378dce] Sending prompt (first 50 chars): 'python pascals tree gen long code explain everythi...'
577
- 2025-06-09 13:24:38,291 - __main__ - INFO - Typing prompt into textarea.
578
- 2025-06-09 13:24:38,870 - __main__ - INFO - Prompt submitted.
579
- 2025-06-09 13:24:38,871 - __main__ - INFO - Checking for 'Agree' button in dialog.
580
- 2025-06-09 13:24:39,905 - __main__ - INFO - 'Agree' button not visible, skipping.
581
- 2025-06-09 13:24:39,906 - __main__ - INFO - [ddd1b72b-d54f-46d0-a3c9-32760b378dce] Prompt sent. Streaming response...
582
- 2025-06-09 13:27:21,691 - streaming - INFO - [StreamProc/PollStream] Content stable for 10.00s. Ending poll.
583
- 2025-06-09 13:27:22,031 - __main__ - INFO - [ddd1b72b-d54f-46d0-a3c9-32760b378dce] Finished streaming response from browser.
584
- 2025-06-09 13:27:22,031 - __main__ - INFO - [ddd1b72b-d54f-46d0-a3c9-32760b378dce] Cleaning up chat session by clicking 'New Chat'.
585
- 2025-06-09 13:27:22,031 - __main__ - INFO - [ddd1b72b-d54f-46d0-a3c9-32760b378dce] Attempting to click 'New Chat' button.
586
- 2025-06-09 13:27:22,120 - __main__ - INFO - [ddd1b72b-d54f-46d0-a3c9-32760b378dce] 'New Chat' button clicked successfully.
587
- 2025-06-09 13:27:22,120 - streaming - INFO - [chatcmpl-8397b786dfc94d6fa186bf302fdb5091] Yielding final chunk. Total content length: 26526 chars.
588
- 2025-06-09 13:27:22,121 - streaming - INFO - [chatcmpl-8397b786dfc94d6fa186bf302fdb5091] Yielding [DONE] signal.
589
- 2025-06-09 13:29:20,701 - __main__ - INFO - Application shutdown sequence initiated.
590
- 2025-06-09 13:29:20,702 - __main__ - INFO - Cleaning up and quitting Selenium driver...
591
- 2025-06-09 13:29:23,130 - __main__ - INFO - Driver quit successfully.
592
- 2025-06-09 13:29:23,130 - __main__ - INFO - Application shutdown sequence completed.
593
- 2025-06-09 13:29:42,779 - __main__ - INFO - Configuration loaded.
594
- 2025-06-09 13:29:42,787 - __main__ - INFO - DriverManager instance created.
595
- 2025-06-09 13:29:43,278 - __main__ - INFO - Gemini client initialized successfully.
596
- 2025-06-09 13:29:43,312 - __main__ - INFO - GEMINI_API_KEY is set.
597
- 2025-06-09 13:29:43,312 - __main__ - INFO - Starting Uvicorn server on 0.0.0.0:8000.
598
- 2025-06-09 13:29:43,338 - __main__ - INFO - Application startup sequence initiated.
599
- 2025-06-09 13:29:43,339 - __main__ - INFO - Initializing Selenium driver...
600
- 2025-06-09 13:29:43,340 - __main__ - INFO - Executing synchronous driver initialization and enhanced readiness check.
601
- 2025-06-09 13:29:46,450 - __main__ - INFO - Driver instantiated. Opening URL...
602
- 2025-06-09 13:29:51,744 - __main__ - INFO - URL 'https://beta.lmarena.ai/?mode=direct' opened.
603
- 2025-06-09 13:29:51,745 - __main__ - INFO - Attempting to solve initial (Cloudflare-style) captcha with uc_gui_click_captcha()...
604
- 2025-06-09 13:30:03,036 - __main__ - INFO - uc_gui_click_captcha() completed. Main site should be loading now.
605
- 2025-06-09 13:30:03,036 - __main__ - INFO - Checking for on-site ('Verify Human') captcha...
606
- 2025-06-09 13:30:13,135 - __main__ - INFO - No on-site captcha detected. Main UI is ready.
607
- 2025-06-09 13:30:13,136 - __main__ - INFO - Selenium driver initialization process completed successfully.
608
- 2025-06-09 13:30:13,136 - __main__ - INFO - Application startup sequence completed successfully.
609
- 2025-06-09 13:30:42,946 - __main__ - INFO - [chatcmpl-0977bf5aff9b43f3889a3eee2ff0c0c8] Received chat completion request: model='Qwen no Think', stream=True, md_convert=True
610
- 2025-06-09 13:30:42,953 - streaming - INFO - [chatcmpl-0977bf5aff9b43f3889a3eee2ff0c0c8] Starting streaming response for model 'Qwen no Think'
611
- 2025-06-09 13:30:42,953 - __main__ - INFO - [8dca5736-454b-4a53-afc7-9a1356f5609a] Starting chat. Model: 'Qwen no Think', RawHTML: False, MarkdownMode: True.
612
- 2025-06-09 13:30:42,953 - __main__ - INFO - Selecting model: Qwen no Think
613
- 2025-06-09 13:30:43,303 - __main__ - INFO - Selected model: Qwen no Think
614
- 2025-06-09 13:30:43,304 - __main__ - INFO - [8dca5736-454b-4a53-afc7-9a1356f5609a] Sending prompt (first 50 chars): 'python pascals tree gen long code explain everythi...'
615
- 2025-06-09 13:30:43,304 - __main__ - INFO - Typing prompt into textarea.
616
- 2025-06-09 13:30:43,961 - __main__ - INFO - Prompt submitted.
617
- 2025-06-09 13:30:43,962 - __main__ - INFO - Checking for 'Agree' button in dialog.
618
- 2025-06-09 13:30:44,084 - __main__ - INFO - 'Agree' button not visible, skipping.
619
- 2025-06-09 13:30:44,084 - __main__ - INFO - [8dca5736-454b-4a53-afc7-9a1356f5609a] Prompt sent. Streaming response...
620
- 2025-06-09 13:30:47,172 - streaming - INFO - [StreamProc/Poll] Starting content polling
621
- 2025-06-09 13:31:42,729 - streaming - INFO - [StreamProc/Poll] Content stable for 11.1s, ending stream
622
- 2025-06-09 13:31:42,763 - streaming - INFO - Stream metrics: 1253 polls, 539 changes, 29,442,690 bytes in 55.59s
623
- 2025-06-09 13:31:42,763 - __main__ - INFO - [8dca5736-454b-4a53-afc7-9a1356f5609a] Finished streaming response from browser.
624
- 2025-06-09 13:31:42,763 - __main__ - INFO - [8dca5736-454b-4a53-afc7-9a1356f5609a] Cleaning up chat session by clicking 'New Chat'.
625
- 2025-06-09 13:31:42,764 - __main__ - INFO - [8dca5736-454b-4a53-afc7-9a1356f5609a] Attempting to click 'New Chat' button.
626
- 2025-06-09 13:31:42,872 - __main__ - INFO - [8dca5736-454b-4a53-afc7-9a1356f5609a] 'New Chat' button clicked successfully.
627
- 2025-06-09 13:31:42,873 - streaming - INFO - [chatcmpl-0977bf5aff9b43f3889a3eee2ff0c0c8] Streaming complete. Total content: 360 chars
628
- 2025-06-09 13:33:24,447 - __main__ - INFO - Application shutdown sequence initiated.
629
- 2025-06-09 13:33:24,447 - __main__ - INFO - Cleaning up and quitting Selenium driver...
630
- 2025-06-09 13:33:26,769 - __main__ - INFO - Driver quit successfully.
631
- 2025-06-09 13:33:26,769 - __main__ - INFO - Application shutdown sequence completed.
632
- 2025-06-09 13:34:01,581 - __main__ - INFO - Configuration loaded.
633
- 2025-06-09 13:34:01,589 - __main__ - INFO - DriverManager instance created.
634
- 2025-06-09 13:34:02,081 - __main__ - INFO - Gemini client initialized successfully.
635
- 2025-06-09 13:34:02,114 - __main__ - INFO - GEMINI_API_KEY is set.
636
- 2025-06-09 13:34:02,115 - __main__ - INFO - Starting Uvicorn server on 0.0.0.0:8000.
637
- 2025-06-09 13:34:02,141 - __main__ - INFO - Application startup sequence initiated.
638
- 2025-06-09 13:34:02,141 - __main__ - INFO - Initializing Selenium driver...
639
- 2025-06-09 13:34:02,143 - __main__ - INFO - Executing synchronous driver initialization and enhanced readiness check.
640
- 2025-06-09 13:34:05,208 - __main__ - INFO - Driver instantiated. Opening URL...
641
- 2025-06-09 13:34:10,548 - __main__ - INFO - URL 'https://beta.lmarena.ai/?mode=direct' opened.
642
- 2025-06-09 13:34:10,549 - __main__ - INFO - Attempting to solve initial (Cloudflare-style) captcha with uc_gui_click_captcha()...
643
- 2025-06-09 13:34:10,922 - __main__ - INFO - uc_gui_click_captcha() completed. Main site should be loading now.
644
- 2025-06-09 13:34:10,922 - __main__ - INFO - Checking for on-site ('Verify Human') captcha...
645
- 2025-06-09 13:34:21,031 - __main__ - INFO - Textarea not ready or an on-site captcha indicator was found. Proceeding with AI solver.
646
- 2025-06-09 13:34:21,031 - __main__ - INFO - Starting visual AI check for on-site captcha.
647
- 2025-06-09 13:34:21,207 - __main__ - INFO - Sending screenshot to Gemini API for analysis.
648
- 2025-06-09 13:34:21,208 - google_genai.models - INFO - AFC is enabled with max remote calls: 10.
649
- 2025-06-09 13:34:21,208 - google_genai.models - INFO - AFC remote call 1 is done.
650
- 2025-06-09 13:34:23,882 - httpx - INFO - HTTP Request: POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:streamGenerateContent?alt=sse "HTTP/1.1 200 OK"
651
- 2025-06-09 13:34:24,045 - __main__ - INFO - Received Gemini response for on-site captcha check: ```json
652
- [
653
- {"box_2d": [720, 412, 757, 431], "label": "box"}
654
- ]
655
- ```
656
- 2025-06-09 13:34:24,045 - __main__ - INFO - On-site captcha checkbox found via Gemini. Clicking coordinates: {'box_2d': [720, 412, 757, 431], 'label': 'box'}
657
- 2025-06-09 13:34:27,822 - __main__ - INFO - Click performed. Now reloading page as requested for post-AI solve.
658
- 2025-06-09 13:34:27,823 - __main__ - INFO - Performing human-like page reload
659
- 2025-06-09 13:34:27,823 - __main__ - INFO - Using F5 key
660
- 2025-06-09 13:34:28,965 - __main__ - INFO - Page reloaded after 1.04s delay
661
- 2025-06-09 13:34:33,967 - __main__ - INFO - Selenium driver initialization process completed successfully.
662
- 2025-06-09 13:34:33,968 - __main__ - INFO - Application startup sequence completed successfully.
663
- 2025-06-09 13:34:42,463 - __main__ - INFO - [chatcmpl-7a355706384e4df3a77f1c6dc66ca4be] Received chat completion request: model='Qwen no Think', stream=True, md_convert=True
664
- 2025-06-09 13:34:42,470 - streaming - INFO - [chatcmpl-7a355706384e4df3a77f1c6dc66ca4be] Starting streaming response for model 'Qwen no Think'
665
- 2025-06-09 13:34:42,470 - __main__ - INFO - [fa42552d-73dc-4eee-bc0f-55a4ce19a39a] Starting chat. Model: 'Qwen no Think', RawHTML: False, MarkdownMode: True.
666
- 2025-06-09 13:34:42,471 - __main__ - INFO - Selecting model: Qwen no Think
667
- 2025-06-09 13:34:42,761 - __main__ - INFO - Selected model: Qwen no Think
668
- 2025-06-09 13:34:42,761 - __main__ - INFO - [fa42552d-73dc-4eee-bc0f-55a4ce19a39a] Sending prompt (first 50 chars): 'bionomial thoerem calc in python concise code but ...'
669
- 2025-06-09 13:34:42,762 - __main__ - INFO - Typing prompt into textarea.
670
- 2025-06-09 13:34:43,244 - __main__ - INFO - Prompt submitted.
671
- 2025-06-09 13:34:43,244 - __main__ - INFO - Checking for 'Agree' button in dialog.
672
- 2025-06-09 13:34:43,345 - __main__ - INFO - 'Agree' button not visible, skipping.
673
- 2025-06-09 13:34:43,345 - __main__ - INFO - [fa42552d-73dc-4eee-bc0f-55a4ce19a39a] Prompt sent. Streaming response...
674
- 2025-06-09 13:34:45,905 - __main__ - ERROR - Streaming error: StreamConfig.__init__() got an unexpected keyword argument 'stabilization_timeout'
675
- Traceback (most recent call last):
676
- File "c:\Users\caree\Code\Lmarena\api.py", line 414, in _stream_response
677
- stream_config = StreamConfig(
678
- poll_interval=config.poll_interval,
679
- ...<4 lines>...
680
- convert_html_to_markdown=convert_html_to_markdown
681
- )
682
- TypeError: StreamConfig.__init__() got an unexpected keyword argument 'stabilization_timeout'
683
- 2025-06-09 13:34:45,907 - __main__ - INFO - [fa42552d-73dc-4eee-bc0f-55a4ce19a39a] Finished streaming response from browser.
684
- 2025-06-09 13:34:45,907 - __main__ - INFO - [fa42552d-73dc-4eee-bc0f-55a4ce19a39a] Cleaning up chat session by clicking 'New Chat'.
685
- 2025-06-09 13:34:45,907 - __main__ - INFO - [fa42552d-73dc-4eee-bc0f-55a4ce19a39a] Attempting to click 'New Chat' button.
686
- 2025-06-09 13:34:46,048 - __main__ - INFO - [fa42552d-73dc-4eee-bc0f-55a4ce19a39a] 'New Chat' button clicked successfully.
687
- 2025-06-09 13:34:46,049 - streaming - INFO - [chatcmpl-7a355706384e4df3a77f1c6dc66ca4be] Streaming complete. Sent 1 chunks, total: 91 chars
688
- 2025-06-09 13:36:40,674 - __main__ - INFO - Configuration loaded.
689
- 2025-06-09 13:36:40,682 - __main__ - INFO - DriverManager instance created.
690
- 2025-06-09 13:36:41,181 - __main__ - INFO - Gemini client initialized successfully.
691
- 2025-06-09 13:36:41,214 - __main__ - INFO - GEMINI_API_KEY is set.
692
- 2025-06-09 13:36:41,214 - __main__ - INFO - Starting Uvicorn server on 0.0.0.0:8000.
693
- 2025-06-09 13:36:41,240 - __main__ - INFO - Application startup sequence initiated.
694
- 2025-06-09 13:36:41,241 - __main__ - INFO - Initializing Selenium driver...
695
- 2025-06-09 13:36:41,243 - __main__ - INFO - Executing synchronous driver initialization and enhanced readiness check.
696
- 2025-06-09 13:36:44,311 - __main__ - INFO - Driver instantiated. Opening URL...
697
- 2025-06-09 13:36:50,037 - __main__ - INFO - URL 'https://beta.lmarena.ai/?mode=direct' opened.
698
- 2025-06-09 13:36:50,037 - __main__ - INFO - Attempting to solve initial (Cloudflare-style) captcha with uc_gui_click_captcha()...
699
- 2025-06-09 13:36:50,534 - __main__ - INFO - uc_gui_click_captcha() completed. Main site should be loading now.
700
- 2025-06-09 13:36:50,534 - __main__ - INFO - Checking for on-site ('Verify Human') captcha...
701
- 2025-06-09 13:37:00,639 - __main__ - INFO - Textarea not ready or an on-site captcha indicator was found. Proceeding with AI solver.
702
- 2025-06-09 13:37:00,639 - __main__ - INFO - Starting visual AI check for on-site captcha.
703
- 2025-06-09 13:37:00,795 - __main__ - INFO - Sending screenshot to Gemini API for analysis.
704
- 2025-06-09 13:37:00,796 - google_genai.models - INFO - AFC is enabled with max remote calls: 10.
705
- 2025-06-09 13:37:00,796 - google_genai.models - INFO - AFC remote call 1 is done.
706
- 2025-06-09 13:37:03,575 - httpx - INFO - HTTP Request: POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:streamGenerateContent?alt=sse "HTTP/1.1 200 OK"
707
- 2025-06-09 13:37:03,688 - __main__ - INFO - Received Gemini response for on-site captcha check: ```json
708
- [
709
- {"box_2d": [722, 412, 754, 431], "label": "box"}
710
- ]
711
- ```
712
- 2025-06-09 13:37:03,689 - __main__ - INFO - On-site captcha checkbox found via Gemini. Clicking coordinates: {'box_2d': [722, 412, 754, 431], 'label': 'box'}
713
- 2025-06-09 13:37:07,369 - __main__ - INFO - Click performed. Now reloading page as requested for post-AI solve.
714
- 2025-06-09 13:37:07,370 - __main__ - INFO - Performing human-like page reload
715
- 2025-06-09 13:37:07,370 - __main__ - INFO - Using FN+F5 key combination
716
- 2025-06-09 13:37:08,832 - __main__ - INFO - Page reloaded after 0.56s delay
717
- 2025-06-09 13:37:13,834 - __main__ - INFO - Selenium driver initialization process completed successfully.
718
- 2025-06-09 13:37:13,834 - __main__ - INFO - Application startup sequence completed successfully.
719
- 2025-06-09 13:37:17,850 - __main__ - INFO - [chatcmpl-5b3f2aabac7849ddb66938c955880bf8] Received chat completion request: model='Gemini 2.0', stream=True, md_convert=True
720
- 2025-06-09 13:37:17,857 - streaming - INFO - [chatcmpl-5b3f2aabac7849ddb66938c955880bf8] Starting streaming response for model 'Gemini 2.0'
721
- 2025-06-09 13:37:17,857 - __main__ - INFO - [7060fd0f-7d80-4957-a475-8cd2ab15676c] Starting chat. Model: 'Gemini 2.0', RawHTML: False, MarkdownMode: True.
722
- 2025-06-09 13:37:17,857 - __main__ - INFO - Selecting model: Gemini 2.0
723
- 2025-06-09 13:37:18,193 - __main__ - INFO - Selected model: Gemini 2.0
724
- 2025-06-09 13:37:18,194 - __main__ - INFO - [7060fd0f-7d80-4957-a475-8cd2ab15676c] Sending prompt (first 50 chars): 'bionomial thoerem calc in python concise code but ...'
725
- 2025-06-09 13:37:18,194 - __main__ - INFO - Typing prompt into textarea.
726
- 2025-06-09 13:37:18,784 - __main__ - INFO - Prompt submitted.
727
- 2025-06-09 13:37:18,785 - __main__ - INFO - Checking for 'Agree' button in dialog.
728
- 2025-06-09 13:37:18,884 - __main__ - INFO - 'Agree' button not visible, skipping.
729
- 2025-06-09 13:37:18,884 - __main__ - INFO - [7060fd0f-7d80-4957-a475-8cd2ab15676c] Prompt sent. Streaming response...
730
- 2025-06-09 13:37:29,096 - streaming - INFO - [StreamProc/Poll] Starting content polling
731
- 2025-06-09 13:37:43,597 - streaming - INFO - [StreamProc/Poll] Content stable for 10.0s, ending stream
732
- 2025-06-09 13:37:43,598 - streaming - INFO - [StreamProc/Poll] Polling ended after 14.5s
733
- 2025-06-09 13:37:43,598 - __main__ - INFO - [7060fd0f-7d80-4957-a475-8cd2ab15676c] Finished streaming response from browser.
734
- 2025-06-09 13:37:43,599 - __main__ - INFO - [7060fd0f-7d80-4957-a475-8cd2ab15676c] Cleaning up chat session by clicking 'New Chat'.
735
- 2025-06-09 13:37:43,599 - __main__ - INFO - [7060fd0f-7d80-4957-a475-8cd2ab15676c] Attempting to click 'New Chat' button.
736
- 2025-06-09 13:37:43,686 - __main__ - INFO - [7060fd0f-7d80-4957-a475-8cd2ab15676c] 'New Chat' button clicked successfully.
737
- 2025-06-09 13:37:43,687 - streaming - INFO - [chatcmpl-5b3f2aabac7849ddb66938c955880bf8] Streaming complete. Sent 26 chunks, total: 30702 chars
738
- 2025-06-09 13:37:57,826 - __main__ - INFO - Application shutdown sequence initiated.
739
- 2025-06-09 13:37:57,827 - __main__ - INFO - Cleaning up and quitting Selenium driver...
740
- 2025-06-09 13:38:00,251 - __main__ - INFO - Driver quit successfully.
741
- 2025-06-09 13:38:00,252 - __main__ - INFO - Application shutdown sequence completed.
742
- 2025-06-09 13:38:05,462 - __main__ - INFO - Configuration loaded.
743
- 2025-06-09 13:38:05,476 - __main__ - INFO - DriverManager instance created.
744
- 2025-06-09 13:38:05,982 - __main__ - INFO - Gemini client initialized successfully.
745
- 2025-06-09 13:38:06,014 - __main__ - INFO - GEMINI_API_KEY is set.
746
- 2025-06-09 13:38:06,015 - __main__ - INFO - Starting Uvicorn server on 0.0.0.0:8000.
747
- 2025-06-09 13:38:06,040 - __main__ - INFO - Application startup sequence initiated.
748
- 2025-06-09 13:38:06,041 - __main__ - INFO - Initializing Selenium driver...
749
- 2025-06-09 13:38:06,042 - __main__ - INFO - Executing synchronous driver initialization and enhanced readiness check.
750
- 2025-06-09 13:38:09,109 - __main__ - INFO - Driver instantiated. Opening URL...
751
- 2025-06-09 13:38:16,487 - __main__ - INFO - URL 'https://beta.lmarena.ai/?mode=direct' opened.
752
- 2025-06-09 13:38:16,488 - __main__ - INFO - Attempting to solve initial (Cloudflare-style) captcha with uc_gui_click_captcha()...
753
- 2025-06-09 13:38:17,034 - __main__ - INFO - uc_gui_click_captcha() completed. Main site should be loading now.
754
- 2025-06-09 13:38:17,034 - __main__ - INFO - Checking for on-site ('Verify Human') captcha...
755
- 2025-06-09 13:38:27,140 - __main__ - INFO - Textarea not ready or an on-site captcha indicator was found. Proceeding with AI solver.
756
- 2025-06-09 13:38:27,141 - __main__ - INFO - Starting visual AI check for on-site captcha.
757
- 2025-06-09 13:38:27,292 - __main__ - INFO - Sending screenshot to Gemini API for analysis.
758
- 2025-06-09 13:38:27,293 - google_genai.models - INFO - AFC is enabled with max remote calls: 10.
759
- 2025-06-09 13:38:27,294 - google_genai.models - INFO - AFC remote call 1 is done.
760
- 2025-06-09 13:38:30,360 - httpx - INFO - HTTP Request: POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:streamGenerateContent?alt=sse "HTTP/1.1 200 OK"
761
- 2025-06-09 13:38:30,419 - __main__ - INFO - Received Gemini response for on-site captcha check: ```json
762
- [
763
- {"box_2d": [715, 412, 758, 432], "label": "box"}
764
- ]
765
- ```
766
- 2025-06-09 13:38:30,419 - __main__ - INFO - On-site captcha checkbox found via Gemini. Clicking coordinates: {'box_2d': [715, 412, 758, 432], 'label': 'box'}
767
- 2025-06-09 13:38:34,201 - __main__ - INFO - Click performed. Now reloading page as requested for post-AI solve.
768
- 2025-06-09 13:38:34,202 - __main__ - INFO - Performing human-like page reload
769
- 2025-06-09 13:38:34,202 - __main__ - INFO - Using FN+F5 key combination
770
- 2025-06-09 13:38:36,047 - __main__ - INFO - Page reloaded after 0.94s delay
771
- 2025-06-09 13:38:41,049 - __main__ - INFO - Selenium driver initialization process completed successfully.
772
- 2025-06-09 13:38:41,050 - __main__ - INFO - Application startup sequence completed successfully.
773
- 2025-06-09 13:38:44,622 - __main__ - INFO - [chatcmpl-28b698e36b09432383823c19da3c0335] Received chat completion request: model='Gemini 2.0 Flash', stream=True, md_convert=True
774
- 2025-06-09 13:38:44,629 - streaming - INFO - [chatcmpl-28b698e36b09432383823c19da3c0335] Starting streaming response generation for model 'Gemini 2.0 Flash'.
775
- 2025-06-09 13:38:44,629 - __main__ - INFO - [0c17e458-0e06-47bf-ba50-a1bc3da3d518] Starting chat. Model: 'Gemini 2.0 Flash', RawHTML: False, MarkdownMode: True.
776
- 2025-06-09 13:38:44,630 - __main__ - INFO - Selecting model: Gemini 2.0 Flash
777
- 2025-06-09 13:38:44,985 - __main__ - INFO - Selected model: Gemini 2.0 Flash
778
- 2025-06-09 13:38:44,986 - __main__ - INFO - [0c17e458-0e06-47bf-ba50-a1bc3da3d518] Sending prompt (first 50 chars): 'bionomial thoerem calc in python concise code but ...'
779
- 2025-06-09 13:38:44,986 - __main__ - INFO - Typing prompt into textarea.
780
- 2025-06-09 13:38:45,522 - __main__ - INFO - Prompt submitted.
781
- 2025-06-09 13:38:45,523 - __main__ - INFO - Checking for 'Agree' button in dialog.
782
- 2025-06-09 13:38:45,612 - __main__ - INFO - 'Agree' button not visible, skipping.
783
- 2025-06-09 13:38:45,612 - __main__ - INFO - [0c17e458-0e06-47bf-ba50-a1bc3da3d518] Prompt sent. Streaming response...
784
- 2025-06-09 13:39:06,675 - streaming - INFO - [StreamProc/PollStream] Content stable for 10.00s. Ending poll.
785
- 2025-06-09 13:39:06,688 - __main__ - INFO - [0c17e458-0e06-47bf-ba50-a1bc3da3d518] Finished streaming response from browser.
786
- 2025-06-09 13:39:06,689 - __main__ - INFO - [0c17e458-0e06-47bf-ba50-a1bc3da3d518] Cleaning up chat session by clicking 'New Chat'.
787
- 2025-06-09 13:39:06,689 - __main__ - INFO - [0c17e458-0e06-47bf-ba50-a1bc3da3d518] Attempting to click 'New Chat' button.
788
- 2025-06-09 13:39:06,765 - __main__ - INFO - [0c17e458-0e06-47bf-ba50-a1bc3da3d518] 'New Chat' button clicked successfully.
789
- 2025-06-09 13:39:06,766 - streaming - INFO - [chatcmpl-28b698e36b09432383823c19da3c0335] Yielding final chunk. Total content length: 3937 chars.
790
- 2025-06-09 13:39:06,766 - streaming - INFO - [chatcmpl-28b698e36b09432383823c19da3c0335] Yielding [DONE] signal.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
sdfhsdf.py DELETED
@@ -1,676 +0,0 @@
1
- """
2
- Pascal's Tree Generator - A Comprehensive Implementation
3
- ======================================================
4
-
5
- This module implements multiple interpretations of Pascal's tree:
6
- 1. Binary tree where each node contains Pascal's triangle values
7
- 2. Tree representation showing the recursive nature of Pascal's triangle
8
- 3. Path-based tree showing how Pascal values are constructed
9
- """
10
-
11
- import math
12
- from typing import List, Optional, Tuple, Dict, Any
13
- from collections import deque
14
- import matplotlib.pyplot as plt
15
- import networkx as nx
16
- from dataclasses import dataclass
17
- import numpy as np
18
-
19
-
20
- @dataclass
21
- class TreeNode:
22
- """
23
- Represents a node in Pascal's tree.
24
-
25
- Attributes:
26
- value: The numeric value at this node (from Pascal's triangle)
27
- row: The row in Pascal's triangle (0-indexed)
28
- col: The column in Pascal's triangle (0-indexed)
29
- left: Left child node
30
- right: Right child node
31
- parent: Parent node reference
32
- coefficient: The binomial coefficient C(row, col)
33
- """
34
- value: int
35
- row: int
36
- col: int
37
- left: Optional['TreeNode'] = None
38
- right: Optional['TreeNode'] = None
39
- parent: Optional['TreeNode'] = None
40
- coefficient: Optional[int] = None
41
-
42
- def __post_init__(self):
43
- # Calculate binomial coefficient if not provided
44
- if self.coefficient is None:
45
- self.coefficient = self._calculate_binomial_coefficient()
46
-
47
- def _calculate_binomial_coefficient(self) -> int:
48
- """
49
- Calculate C(n, k) = n! / (k! * (n-k)!)
50
- Using the multiplicative formula for efficiency
51
- """
52
- if self.col > self.row or self.col < 0:
53
- return 0
54
- if self.col == 0 or self.col == self.row:
55
- return 1
56
-
57
- # Use symmetry property: C(n, k) = C(n, n-k)
58
- k = min(self.col, self.row - self.col)
59
-
60
- result = 1
61
- for i in range(k):
62
- result = result * (self.row - i) // (i + 1)
63
-
64
- return result
65
-
66
-
67
- class PascalTreeGenerator:
68
- """
69
- Main class for generating various forms of Pascal's tree.
70
-
71
- This class implements multiple algorithms for constructing Pascal's tree,
72
- each highlighting different mathematical properties and relationships.
73
- """
74
-
75
- def __init__(self):
76
- self.root = None
77
- self.nodes_by_position = {} # (row, col) -> TreeNode
78
- self.level_nodes = {} # row -> List[TreeNode]
79
-
80
- def generate_recursive_tree(self, max_depth: int) -> TreeNode:
81
- """
82
- Generate Pascal's tree using recursive construction.
83
-
84
- This method creates a binary tree where:
85
- - Each node (n, k) has value C(n, k)
86
- - Left child is (n+1, k)
87
- - Right child is (n+1, k+1)
88
-
89
- This represents the recursive property:
90
- C(n+1, k) + C(n+1, k+1) = C(n+2, k+1)
91
-
92
- Args:
93
- max_depth: Maximum depth of the tree
94
-
95
- Returns:
96
- Root node of the tree
97
- """
98
- self.root = self._build_recursive_node(0, 0, max_depth)
99
- return self.root
100
-
101
- def _build_recursive_node(self, row: int, col: int, max_depth: int,
102
- parent: Optional[TreeNode] = None) -> Optional[TreeNode]:
103
- """
104
- Recursively build tree nodes.
105
-
106
- The mathematical insight here is that Pascal's triangle can be
107
- constructed by the recurrence relation:
108
- C(n, k) = C(n-1, k-1) + C(n-1, k)
109
-
110
- We're building the tree in the forward direction, showing how
111
- each value contributes to values in subsequent rows.
112
- """
113
- if row > max_depth or col > row or col < 0:
114
- return None
115
-
116
- # Create node with binomial coefficient value
117
- node = TreeNode(
118
- value=math.comb(row, col), # Python 3.8+ built-in
119
- row=row,
120
- col=col,
121
- parent=parent
122
- )
123
-
124
- # Store node reference for later access
125
- self.nodes_by_position[(row, col)] = node
126
-
127
- if row not in self.level_nodes:
128
- self.level_nodes[row] = []
129
- self.level_nodes[row].append(node)
130
-
131
- # Build children representing contributions to next row
132
- node.left = self._build_recursive_node(row + 1, col, max_depth, node)
133
- node.right = self._build_recursive_node(row + 1, col + 1, max_depth, node)
134
-
135
- return node
136
-
137
- def generate_path_sum_tree(self, max_depth: int) -> TreeNode:
138
- """
139
- Generate a tree where paths from root represent the construction
140
- of Pascal's triangle values through path counting.
141
-
142
- Mathematical principle: C(n, k) equals the number of paths from
143
- (0, 0) to (n, k) moving only right or down in a grid.
144
-
145
- In tree form:
146
- - Left branch represents "choosing" an element
147
- - Right branch represents "not choosing" an element
148
- """
149
- self.root = TreeNode(value=1, row=0, col=0)
150
- self._build_path_tree(self.root, max_depth)
151
- return self.root
152
-
153
- def _build_path_tree(self, node: TreeNode, remaining_depth: int):
154
- """
155
- Build tree based on path counting interpretation.
156
-
157
- Each path from root to a node at depth n with k left turns
158
- represents one of the C(n, k) ways to choose k items from n items.
159
- """
160
- if remaining_depth <= 0:
161
- return
162
-
163
- # Left child: "choose" (increment both row and col)
164
- node.left = TreeNode(
165
- value=node.value, # Path count remains same along each path
166
- row=node.row + 1,
167
- col=node.col + 1,
168
- parent=node
169
- )
170
-
171
- # Right child: "don't choose" (increment only row)
172
- node.right = TreeNode(
173
- value=node.value,
174
- row=node.row + 1,
175
- col=node.col,
176
- parent=node
177
- )
178
-
179
- # Recursively build subtrees
180
- self._build_path_tree(node.left, remaining_depth - 1)
181
- self._build_path_tree(node.right, remaining_depth - 1)
182
-
183
- def generate_sierpinski_tree(self, max_depth: int) -> TreeNode:
184
- """
185
- Generate Pascal's tree with Sierpinski triangle properties.
186
-
187
- Mathematical insight: When Pascal's triangle values are taken
188
- modulo 2, the resulting pattern is the Sierpinski triangle.
189
-
190
- This tree structure highlights the fractal nature of Pascal's
191
- triangle and its connection to cellular automata.
192
- """
193
- self.root = TreeNode(value=1, row=0, col=0)
194
- self._build_sierpinski_node(self.root, max_depth)
195
- return self.root
196
-
197
- def _build_sierpinski_node(self, node: TreeNode, remaining_depth: int):
198
- """
199
- Build tree with Sierpinski triangle properties.
200
-
201
- Odd values in Pascal's triangle form the Sierpinski triangle
202
- pattern. This is related to Lucas' theorem about binomial
203
- coefficients modulo primes.
204
- """
205
- if remaining_depth <= 0:
206
- return
207
-
208
- # Calculate children values using the recurrence relation
209
- left_val = self._get_pascal_value(node.row + 1, node.col)
210
- right_val = self._get_pascal_value(node.row + 1, node.col + 1)
211
-
212
- # Create children with modulo 2 coloring for Sierpinski
213
- if left_val > 0: # Valid position in triangle
214
- node.left = TreeNode(
215
- value=left_val,
216
- row=node.row + 1,
217
- col=node.col,
218
- parent=node
219
- )
220
- node.left.sierpinski_bit = left_val % 2
221
- self._build_sierpinski_node(node.left, remaining_depth - 1)
222
-
223
- if right_val > 0: # Valid position in triangle
224
- node.right = TreeNode(
225
- value=right_val,
226
- row=node.row + 1,
227
- col=node.col + 1,
228
- parent=node
229
- )
230
- node.right.sierpinski_bit = right_val % 2
231
- self._build_sierpinski_node(node.right, remaining_depth - 1)
232
-
233
- def _get_pascal_value(self, row: int, col: int) -> int:
234
- """
235
- Get Pascal's triangle value at (row, col).
236
-
237
- Uses the efficient multiplicative formula rather than
238
- factorial calculation for better performance.
239
- """
240
- if col > row or col < 0:
241
- return 0
242
- if col == 0 or col == row:
243
- return 1
244
-
245
- # Use dynamic programming if we've already calculated it
246
- if (row, col) in self.nodes_by_position:
247
- return self.nodes_by_position[(row, col)].value
248
-
249
- # Calculate using the multiplicative formula
250
- k = min(col, row - col) # Use symmetry
251
- result = 1
252
- for i in range(k):
253
- result = result * (row - i) // (i + 1)
254
-
255
- return result
256
-
257
- def calculate_tree_properties(self, root: TreeNode) -> Dict[str, Any]:
258
- """
259
- Calculate various mathematical properties of the generated tree.
260
-
261
- This includes:
262
- - Sum of values at each level (should equal 2^n)
263
- - Maximum value at each level
264
- - Number of odd values (related to Sierpinski)
265
- - Tree balance metrics
266
- """
267
- properties = {
268
- 'level_sums': {},
269
- 'level_max_values': {},
270
- 'odd_count_by_level': {},
271
- 'total_nodes': 0,
272
- 'leaf_nodes': 0,
273
- 'internal_nodes': 0,
274
- 'max_depth': 0,
275
- 'perfectly_balanced': True
276
- }
277
-
278
- # BFS traversal to calculate properties
279
- queue = deque([(root, 0)])
280
- level_nodes_count = {}
281
-
282
- while queue:
283
- node, depth = queue.popleft()
284
- properties['total_nodes'] += 1
285
- properties['max_depth'] = max(properties['max_depth'], depth)
286
-
287
- # Update level-based statistics
288
- if depth not in properties['level_sums']:
289
- properties['level_sums'][depth] = 0
290
- properties['level_max_values'][depth] = 0
291
- properties['odd_count_by_level'][depth] = 0
292
- level_nodes_count[depth] = 0
293
-
294
- properties['level_sums'][depth] += node.value
295
- properties['level_max_values'][depth] = max(
296
- properties['level_max_values'][depth],
297
- node.value
298
- )
299
-
300
- if node.value % 2 == 1:
301
- properties['odd_count_by_level'][depth] += 1
302
-
303
- level_nodes_count[depth] += 1
304
-
305
- # Check if leaf or internal node
306
- if node.left is None and node.right is None:
307
- properties['leaf_nodes'] += 1
308
- else:
309
- properties['internal_nodes'] += 1
310
- if node.left:
311
- queue.append((node.left, depth + 1))
312
- if node.right:
313
- queue.append((node.right, depth + 1))
314
-
315
- # Verify mathematical properties
316
- properties['level_sum_verification'] = {}
317
- for level, sum_val in properties['level_sums'].items():
318
- expected = 2 ** level # Sum of row n in Pascal's triangle
319
- properties['level_sum_verification'][level] = {
320
- 'actual': sum_val,
321
- 'expected': expected,
322
- 'correct': sum_val == expected
323
- }
324
-
325
- # Check if tree is perfectly balanced
326
- for level in range(properties['max_depth']):
327
- expected_nodes = 2 ** level
328
- if level_nodes_count[level] != expected_nodes:
329
- properties['perfectly_balanced'] = False
330
- break
331
-
332
- return properties
333
-
334
- def visualize_tree(self, root: TreeNode, filename: str = 'pascal_tree.png',
335
- show_values: bool = True, show_sierpinski: bool = False):
336
- """
337
- Create a visual representation of Pascal's tree.
338
-
339
- Uses networkx and matplotlib to create a hierarchical layout
340
- that clearly shows the tree structure and values.
341
- """
342
- G = nx.DiGraph()
343
- pos = {}
344
- labels = {}
345
- colors = []
346
-
347
- # Build graph using BFS
348
- queue = deque([(root, 0, 0)]) # node, x_position, depth
349
- x_offset = 2 ** 6 # Initial horizontal spacing
350
-
351
- while queue:
352
- node, x, depth = queue.popleft()
353
- node_id = f"{node.row},{node.col}"
354
-
355
- G.add_node(node_id)
356
- pos[node_id] = (x, -depth)
357
-
358
- if show_values:
359
- labels[node_id] = str(node.value)
360
- else:
361
- labels[node_id] = f"({node.row},{node.col})"
362
-
363
- # Color based on Sierpinski pattern (odd/even)
364
- if show_sierpinski:
365
- colors.append('red' if node.value % 2 == 1 else 'lightblue')
366
- else:
367
- # Color based on value magnitude
368
- colors.append(node.value)
369
-
370
- # Add edges and queue children
371
- current_offset = x_offset / (2 ** (depth + 1))
372
-
373
- if node.left:
374
- left_id = f"{node.left.row},{node.left.col}"
375
- G.add_edge(node_id, left_id)
376
- queue.append((node.left, x - current_offset, depth + 1))
377
-
378
- if node.right:
379
- right_id = f"{node.right.row},{node.right.col}"
380
- G.add_edge(node_id, right_id)
381
- queue.append((node.right, x + current_offset, depth + 1))
382
-
383
- # Create visualization
384
- plt.figure(figsize=(15, 10))
385
-
386
- if show_sierpinski:
387
- nx.draw(G, pos, labels=labels, node_color=colors,
388
- node_size=500, font_size=10, font_weight='bold',
389
- with_labels=True, arrows=False)
390
- else:
391
- nx.draw(G, pos, labels=labels, node_color=colors,
392
- cmap='YlOrRd', node_size=500, font_size=10,
393
- font_weight='bold', with_labels=True, arrows=False)
394
-
395
- plt.title("Pascal's Tree Visualization", fontsize=16)
396
- plt.axis('off')
397
- plt.tight_layout()
398
- plt.savefig(filename, dpi=300, bbox_inches='tight')
399
- plt.close()
400
-
401
- def print_tree_text(self, root: TreeNode, max_depth: int = 5):
402
- """
403
- Print a text representation of Pascal's tree.
404
-
405
- Uses indentation to show tree structure and includes
406
- mathematical annotations.
407
- """
408
- print("Pascal's Tree - Text Representation")
409
- print("=" * 50)
410
- print("Format: value [C(row,col)] (row,col)")
411
- print("=" * 50)
412
-
413
- self._print_node_recursive(root, "", True, 0, max_depth)
414
-
415
- def _print_node_recursive(self, node: Optional[TreeNode], prefix: str,
416
- is_tail: bool, depth: int, max_depth: int):
417
- """
418
- Recursively print tree nodes with proper formatting.
419
- """
420
- if node is None or depth > max_depth:
421
- return
422
-
423
- # Create the connection line
424
- connector = "└── " if is_tail else "├── "
425
-
426
- # Print current node
427
- print(f"{prefix}{connector}{node.value} [C({node.row},{node.col})] "
428
- f"({node.row},{node.col})")
429
-
430
- # Prepare prefix for children
431
- child_prefix = prefix + (" " if is_tail else "│ ")
432
-
433
- # Print children
434
- children = []
435
- if node.left:
436
- children.append(node.left)
437
- if node.right:
438
- children.append(node.right)
439
-
440
- for i, child in enumerate(children):
441
- is_last = (i == len(children) - 1)
442
- self._print_node_recursive(child, child_prefix, is_last,
443
- depth + 1, max_depth)
444
-
445
- def generate_fibonacci_connection_tree(self, max_depth: int) -> TreeNode:
446
- """
447
- Generate a tree that highlights the connection between Pascal's
448
- triangle and Fibonacci numbers.
449
-
450
- Mathematical insight: The sum of the nth diagonal in Pascal's
451
- triangle equals the nth Fibonacci number.
452
-
453
- Specifically: F(n) = Σ C(k, n-k-1) for k from 0 to floor(n/2)
454
- """
455
- # Build standard Pascal tree first
456
- self.root = self.generate_recursive_tree(max_depth)
457
-
458
- # Annotate nodes with Fibonacci diagonal sums
459
- self._annotate_fibonacci_diagonals(self.root)
460
-
461
- return self.root
462
-
463
- def _annotate_fibonacci_diagonals(self, root: TreeNode):
464
- """
465
- Annotate tree nodes with their contribution to Fibonacci numbers.
466
-
467
- Each diagonal starting from the edge of Pascal's triangle
468
- sums to a Fibonacci number.
469
- """
470
- # Calculate diagonal sums
471
- diagonal_sums = {}
472
-
473
- queue = deque([root])
474
- while queue:
475
- node = queue.popleft()
476
-
477
- # Diagonal index: d = row - col
478
- diagonal = node.row - node.col
479
-
480
- if diagonal not in diagonal_sums:
481
- diagonal_sums[diagonal] = 0
482
-
483
- diagonal_sums[diagonal] += node.value
484
-
485
- # Store Fibonacci connection in node
486
- node.fibonacci_diagonal = diagonal
487
- node.fibonacci_contribution = node.value
488
-
489
- if node.left:
490
- queue.append(node.left)
491
- if node.right:
492
- queue.append(node.right)
493
-
494
- # Verify Fibonacci property
495
- print("\nFibonacci-Pascal Connection:")
496
- print("Diagonal Index -> Sum = Fibonacci Number")
497
- fib_a, fib_b = 1, 1
498
- for d in sorted(diagonal_sums.keys()):
499
- if d >= 0:
500
- print(f"Diagonal {d}: Sum = {diagonal_sums[d]}, "
501
- f"Fibonacci F({d+1}) = {fib_a}")
502
- fib_a, fib_b = fib_b, fib_a + fib_b
503
-
504
- def analyze_combinatorial_interpretations(self, max_rows: int):
505
- """
506
- Analyze various combinatorial interpretations of Pascal's tree values.
507
-
508
- This includes:
509
- 1. Binomial expansion coefficients
510
- 2. Number of paths in a grid
511
- 3. Number of subsets of a set
512
- 4. Catalan number connections
513
- """
514
- print("\nCombinatorial Interpretations of Pascal's Tree")
515
- print("=" * 60)
516
-
517
- for n in range(max_rows + 1):
518
- print(f"\nRow {n}:")
519
-
520
- # Binomial expansion: (x + y)^n
521
- print(f" Binomial expansion of (x + y)^{n}:")
522
- terms = []
523
- for k in range(n + 1):
524
- coeff = math.comb(n, k)
525
- if k == 0:
526
- terms.append(f"{coeff}x^{n}")
527
- elif k == n:
528
- terms.append(f"{coeff}y^{n}")
529
- else:
530
- terms.append(f"{coeff}x^{n-k}y^{k}")
531
- print(f" {' + '.join(terms)}")
532
-
533
- # Grid paths
534
- print(f" Grid paths from (0,0) to ({n},k):")
535
- for k in range(n + 1):
536
- paths = math.comb(n, k)
537
- print(f" To ({n},{k}): {paths} paths "
538
- f"(choose {k} 'right' moves from {n} total moves)")
539
-
540
- # Subset counting
541
- total_subsets = 2 ** n
542
- print(f" Subsets of a set with {n} elements: {total_subsets} total")
543
- for k in range(n + 1):
544
- subsets_k = math.comb(n, k)
545
- print(f" Subsets of size {k}: {subsets_k}")
546
-
547
- # Catalan numbers connection
548
- print("\n\nCatalan Numbers Connection:")
549
- print("Central binomial coefficients relate to Catalan numbers")
550
- for n in range(min(max_rows + 1, 10)):
551
- central_binom = math.comb(2*n, n)
552
- catalan = central_binom // (n + 1) # nth Catalan number
553
- print(f" C({2*n},{n}) = {central_binom}, "
554
- f"Catalan({n}) = {catalan} = C({2*n},{n})/{n+1}")
555
-
556
-
557
- # Example usage and demonstrations
558
- def demonstrate_pascal_trees():
559
- """
560
- Comprehensive demonstration of Pascal's tree implementations.
561
- """
562
- print("PASCAL'S TREE GENERATOR - COMPREHENSIVE DEMONSTRATION")
563
- print("=" * 70)
564
-
565
- # Create generator instance
566
- generator = PascalTreeGenerator()
567
-
568
- # 1. Generate recursive tree
569
- print("\n1. RECURSIVE PASCAL'S TREE")
570
- print("-" * 40)
571
- recursive_tree = generator.generate_recursive_tree(max_depth=5)
572
- generator.print_tree_text(recursive_tree, max_depth=4)
573
-
574
- # Calculate and display properties
575
- properties = generator.calculate_tree_properties(recursive_tree)
576
- print("\nTree Properties:")
577
- print(f" Total nodes: {properties['total_nodes']}")
578
- print(f" Max depth: {properties['max_depth']}")
579
- print(f" Leaf nodes: {properties['leaf_nodes']}")
580
- print(f" Perfectly balanced: {properties['perfectly_balanced']}")
581
-
582
- print("\nLevel sums (should equal 2^n):")
583
- for level, verification in properties['level_sum_verification'].items():
584
- status = "✓" if verification['correct'] else "✗"
585
- print(f" Level {level}: {verification['actual']} "
586
- f"(expected {verification['expected']}) {status}")
587
-
588
- # 2. Path sum tree
589
- print("\n\n2. PATH SUM TREE")
590
- print("-" * 40)
591
- generator2 = PascalTreeGenerator()
592
- path_tree = generator2.generate_path_sum_tree(max_depth=4)
593
- print("Path sum tree shows how Pascal values can be computed")
594
- print("by counting paths in the tree structure.")
595
-
596
- # 3. Sierpinski tree
597
- print("\n\n3. SIERPINSKI TREE (Pascal's Triangle mod 2)")
598
- print("-" * 40)
599
- generator3 = PascalTreeGenerator()
600
- sierpinski_tree = generator3.generate_sierpinski_tree(max_depth=6)
601
-
602
- print("Odd values in first 7 rows (forms Sierpinski triangle):")
603
- for level in range(7):
604
- row_values = []
605
- for col in range(level + 1):
606
- val = generator3._get_pascal_value(level, col)
607
- row_values.append("●" if val % 2 == 1 else "○")
608
- print(f" Row {level}: {' '.join(row_values)}")
609
-
610
- # 4. Fibonacci connection
611
- print("\n\n4. FIBONACCI CONNECTION TREE")
612
- print("-" * 40)
613
- generator4 = PascalTreeGenerator()
614
- fib_tree = generator4.generate_fibonacci_connection_tree(max_depth=7)
615
-
616
- # 5. Combinatorial analysis
617
- print("\n\n5. COMBINATORIAL INTERPRETATIONS")
618
- print("-" * 40)
619
- generator5 = PascalTreeGenerator()
620
- generator5.analyze_combinatorial_interpretations(max_rows=4)
621
-
622
- # 6. Mathematical relationships
623
- print("\n\n6. MATHEMATICAL RELATIONSHIPS IN PASCAL'S TREE")
624
- print("-" * 40)
625
-
626
- print("\nHockey Stick Identity:")
627
- print("Sum of a column: Σ C(k,r) for k=r to n equals C(n+1,r+1)")
628
- n, r = 6, 2
629
- column_sum = sum(math.comb(k, r) for k in range(r, n+1))
630
- print(f" Example: Σ C(k,{r}) for k={r} to {n} = {column_sum}")
631
- print(f" This equals C({n+1},{r+1}) = {math.comb(n+1, r+1)} ✓")
632
-
633
- print("\nVandermonde's Identity:")
634
- print("C(m+n,r) = Σ C(m,k) * C(n,r-k) for k=0 to r")
635
- m, n, r = 3, 4, 3
636
- left_side = math.comb(m+n, r)
637
- right_side = sum(math.comb(m, k) * math.comb(n, r-k) for k in range(r+1))
638
- print(f" Example: C({m+n},{r}) = {left_side}")
639
- print(f" Sum of products = {right_side} ✓")
640
-
641
- # 7. Generate visualizations
642
- print("\n\n7. GENERATING VISUALIZATIONS")
643
- print("-" * 40)
644
-
645
- # Standard visualization
646
- print("Creating standard Pascal's tree visualization...")
647
- generator.visualize_tree(recursive_tree, 'pascal_tree_standard.png',
648
- show_values=True, show_sierpinski=False)
649
-
650
- # Sierpinski visualization
651
- print("Creating Sierpinski pattern visualization...")
652
- generator3.visualize_tree(sierpinski_tree, 'pascal_tree_sierpinski.png',
653
- show_values=True, show_sierpinski=True)
654
-
655
- print("\nVisualizations saved as:")
656
- print(" - pascal_tree_standard.png")
657
- print(" - pascal_tree_sierpinski.png")
658
-
659
- return generator
660
-
661
-
662
- if __name__ == "__main__":
663
- # Run comprehensive demonstration
664
- generator = demonstrate_pascal_trees()
665
-
666
- print("\n" + "=" * 70)
667
- print("DEMONSTRATION COMPLETE")
668
- print("\nPascal's tree reveals deep mathematical connections between:")
669
- print("- Combinatorics (counting and choosing)")
670
- print("- Number theory (divisibility patterns)")
671
- print("- Fractals (Sierpinski triangle)")
672
- print("- Fibonacci sequences")
673
- print("- Probability theory")
674
- print("- Algebraic expansions")
675
- print("\nThe tree structure provides insights into the recursive")
676
- print("and self-similar nature of Pascal's triangle.")