gemx 0.2.2__tar.gz → 0.2.3__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: gemx
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Drive the Gemini web UI from Python via Playwright
5
5
  Project-URL: Homepage, https://github.com/ra0x3/gemx
6
6
  Project-URL: Repository, https://github.com/ra0x3/gemx
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "gemx"
3
- version = "0.2.2"
3
+ version = "0.2.3"
4
4
  description = "Drive the Gemini web UI from Python via Playwright"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -28,4 +28,4 @@ __all__ = [
28
28
  "parse_output",
29
29
  ]
30
30
 
31
- __version__ = "0.2.2"
31
+ __version__ = "0.2.3"
@@ -95,6 +95,7 @@ CANNED_REPLIES = (
95
95
  "i'm having a hard time fulfilling your request",
96
96
  "i seem to be encountering an error",
97
97
  "i encountered an error doing what you asked",
98
+ "something went wrong. please try your request again",
98
99
  )
99
100
 
100
101
 
@@ -180,6 +181,20 @@ _LONGEST_RESPONSE_JS = """(args) => {
180
181
  return { text: best, selector, length: best.length };
181
182
  }"""
182
183
 
184
+ _LIVE_RESPONSES_JS = """(args) => {
185
+ const [selectors, initialCounts] = args;
186
+ const texts = [];
187
+ selectors.forEach(sel => {
188
+ const els = Array.from(document.querySelectorAll(sel));
189
+ const initial = initialCounts[sel] || 0;
190
+ els.slice(initial).forEach(el => {
191
+ const t = el.innerText || el.textContent || '';
192
+ if (t) texts.push(t);
193
+ });
194
+ });
195
+ return texts;
196
+ }"""
197
+
183
198
  _PAGE_ELEMENTS_JS = """() => {
184
199
  return {
185
200
  hasTextarea: document.querySelector('textarea') !== null,
@@ -573,14 +588,20 @@ class Gemx:
573
588
  current_length,
574
589
  len(best),
575
590
  )
576
- if (
577
- stable >= cfg.stable_ticks
578
- and expected_format in (OutputFormat.JSON, OutputFormat.XML)
579
- and is_canned_reply(best)
591
+ if stable >= cfg.stable_ticks and expected_format in (
592
+ OutputFormat.JSON,
593
+ OutputFormat.XML,
580
594
  ):
581
- raise ResponseTimeoutError(
582
- f"Gemini returned a canned reply: {best[:200]!r}"
595
+ live = await page.evaluate(
596
+ _LIVE_RESPONSES_JS, [list(RESPONSE_SELECTORS), initial_counts]
597
+ )
598
+ canned = next(
599
+ (t for t in [best, *live] if is_canned_reply(t)), None
583
600
  )
601
+ if canned is not None:
602
+ raise ResponseTimeoutError(
603
+ f"Gemini returned a canned reply: {canned[:200]!r}"
604
+ )
584
605
  if stable >= cfg.stable_ticks and len(best) > cfg.min_response_chars:
585
606
  if expected_format in (OutputFormat.JSON, OutputFormat.XML):
586
607
  try:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes