browser-assistant 2.9.25 → 2.9.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extension/manifest.json +1 -1
- package/package.json +1 -1
- package/server/main.py +5 -2
- package/server/vision_images.py +29 -9
package/extension/manifest.json
CHANGED
package/package.json
CHANGED
package/server/main.py
CHANGED
|
@@ -29,7 +29,7 @@ from vision_images import (compress_image_base64, unique_image_blocks, collect_i
|
|
|
29
29
|
answer_permutation, cross_check_text_answers, solve_matrix_choice, solve_row_parallel_choice,
|
|
30
30
|
solve_relu_parallel_choice,
|
|
31
31
|
ordering_question, solve_sorted_list_merge_order, solve_stack_empty_order, solve_pseudocode_choice,
|
|
32
|
-
solve_stack_push_order,
|
|
32
|
+
solve_stack_push_order, solve_stack_pop_order,
|
|
33
33
|
reading_response_constraints,
|
|
34
34
|
VisionRateLimitError, VisionUnconfirmedError)
|
|
35
35
|
|
|
@@ -194,7 +194,7 @@ async def lifespan(_app: FastAPI):
|
|
|
194
194
|
client.close()
|
|
195
195
|
|
|
196
196
|
|
|
197
|
-
app = FastAPI(title="Browser Assistant API", version="2.9.
|
|
197
|
+
app = FastAPI(title="Browser Assistant API", version="2.9.27", lifespan=lifespan)
|
|
198
198
|
install_local_guards(app)
|
|
199
199
|
|
|
200
200
|
@app.exception_handler(HTTPException)
|
|
@@ -1367,6 +1367,9 @@ REPAIR MODE:
|
|
|
1367
1367
|
if item is None:
|
|
1368
1368
|
item = solve_stack_push_order(ordering)
|
|
1369
1369
|
provider = 'local stack push check'
|
|
1370
|
+
if item is None:
|
|
1371
|
+
item = solve_stack_pop_order(ordering)
|
|
1372
|
+
provider = 'local stack pop check'
|
|
1370
1373
|
if item is not None:
|
|
1371
1374
|
return {"results": json.dumps([item], ensure_ascii=False), "provider": f"{provider} [verified]",
|
|
1372
1375
|
"language": language, "answer_verified": True, "code_reviewed": False}
|
package/server/vision_images.py
CHANGED
|
@@ -228,22 +228,16 @@ def solve_stack_empty_order(ordering):
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
|
|
231
|
-
def
|
|
232
|
-
"""Check the dependencies of a linked-list stack push."""
|
|
231
|
+
def _solve_linked_stack_order(ordering, operation, steps, reasoning):
|
|
233
232
|
if not ordering:
|
|
234
233
|
return None
|
|
235
234
|
prompt, options = ordering
|
|
236
235
|
if not re.fullmatch(
|
|
237
|
-
|
|
236
|
+
rf'arrange the steps in the correct order for the {operation}\s*\(\s*\) operation '
|
|
238
237
|
r'in a stack implemented (?:using|with) a linked list[.:?]?',
|
|
239
238
|
' '.join(prompt.replace('\x60', '').split()), re.I,
|
|
240
239
|
):
|
|
241
240
|
return None
|
|
242
|
-
steps = (
|
|
243
|
-
r'create a new node with temp pointing to it',
|
|
244
|
-
r'(?:point temp\s*->\s*next to (?:the )?top(?: pointer)?|temp\s*->\s*next\s*=\s*top)',
|
|
245
|
-
r'(?:update (?:the )?top(?: pointer)? to temp|top\s*=\s*temp)',
|
|
246
|
-
)
|
|
247
241
|
if len(options) != len(steps):
|
|
248
242
|
return None
|
|
249
243
|
normalized = [' '.join(option.replace('\x60', '').replace('→', '->').split()).lower().rstrip(' .;')
|
|
@@ -254,10 +248,36 @@ def solve_stack_push_order(ordering):
|
|
|
254
248
|
return None
|
|
255
249
|
return {
|
|
256
250
|
'type': 'mcq', 'question': prompt, 'answer': [indices[0] for indices in matches],
|
|
257
|
-
'reasoning':
|
|
251
|
+
'reasoning': reasoning,
|
|
258
252
|
}
|
|
259
253
|
|
|
260
254
|
|
|
255
|
+
def solve_stack_push_order(ordering):
|
|
256
|
+
steps = (
|
|
257
|
+
r'create a new node with temp pointing to it',
|
|
258
|
+
r'(?:point temp\s*->\s*next to (?:the )?top(?: pointer)?|temp\s*->\s*next\s*=\s*top)',
|
|
259
|
+
r'(?:update (?:the )?top(?: pointer)? to temp|top\s*=\s*temp)',
|
|
260
|
+
)
|
|
261
|
+
return _solve_linked_stack_order(
|
|
262
|
+
ordering, 'push', steps, 'Allocate temp first, link temp->next to the old top, then make temp the new top.'
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def solve_stack_pop_order(ordering):
|
|
267
|
+
steps = (
|
|
268
|
+
r'check (?:if|whether) the stack is empty using empty\s*\(\s*\)',
|
|
269
|
+
r'(?:create a temp pointer (?:which|that) points to the node the top pointer is pointing to'
|
|
270
|
+
r'|(?:save|store) (?:the )?(?:current )?top(?: pointer)? in temp|temp\s*=\s*top)',
|
|
271
|
+
r'(?:update (?:the )?top(?: pointer)? to|top\s*=)\s*(?:top|temp)\s*->\s*next',
|
|
272
|
+
r'(?:delete the node pointed to by temp|delete temp|free\s*\(\s*temp\s*\))',
|
|
273
|
+
)
|
|
274
|
+
return _solve_linked_stack_order(
|
|
275
|
+
ordering, 'pop', steps,
|
|
276
|
+
'Check for an empty stack first. If it has a node, save the old top in temp, advance top to the next node, '
|
|
277
|
+
'then delete the saved node.',
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
|
|
261
281
|
def ordering_key(value, size):
|
|
262
282
|
if isinstance(value, str):
|
|
263
283
|
try:
|