browser-assistant 2.9.41 → 2.9.42

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.
@@ -18,9 +18,9 @@
18
18
  return error;
19
19
  }
20
20
  function temporary(error) {
21
- // The backend already tried the available vision keys.
21
+ // Retry exhausted vision keys only after their explicit cooldown expires.
22
22
  if (error.code === 'vision_rate_limited')
23
- return false;
23
+ return Number.isFinite(error.retryAfterMs) && error.retryAfterMs > 0;
24
24
  const text = error?.message || '';
25
25
  if (/access denied|forbidden|unauthorized|invalid.api.key|not configured|validation|not.support|model.*(?:not found|not exist)|illustration changed|question changed|context invalidated|extension was reloaded|no readable|unparseable/i.test(text))
26
26
  return false;
@@ -48,7 +48,7 @@
48
48
  catch (error) {
49
49
  if (!active())
50
50
  return null;
51
- if (attempt === attempts || !temporary(error) || error.retryAfterMs > 60_000)
51
+ if (attempt === attempts || !temporary(error) || error.retryAfterMs > 300_000)
52
52
  throw error;
53
53
  onRetry({ attempt: attempt + 1, attempts, message: error.message });
54
54
  // Short waits keep Stop/Pause responsive. Revalidate before the
@@ -57,6 +57,8 @@
57
57
  for (let elapsed = 0; elapsed < delay; elapsed += 100) {
58
58
  if (!active())
59
59
  return null;
60
+ if (!current())
61
+ throw new Error('Question changed while requesting an answer. No answer was selected.');
60
62
  await sleep(Math.min(100, delay - elapsed));
61
63
  }
62
64
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Browser Assistant",
4
- "version": "2.9.41",
4
+ "version": "2.9.42",
5
5
  "description": "Scans webpages for MCQs and coding problems. Powered by Groq (cloud) and Ollama (local fallback).",
6
6
  "permissions": [
7
7
  "activeTab",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-assistant",
3
- "version": "2.9.41",
3
+ "version": "2.9.42",
4
4
  "description": "Chrome extension and local Python backend for exploring webpage questions and coding exercises",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -2,6 +2,10 @@
2
2
  GROQ_API_KEY=
3
3
  GROQ_API_KEY_2=
4
4
  GROQ_API_KEY_3=
5
+ GROQ_API_KEY_4=
6
+ GROQ_API_KEY_5=
7
+ GROQ_API_KEY_6=
8
+ GROQ_API_KEY_7=
5
9
  GROQ_TEXT_MODEL=openai/gpt-oss-120b
6
10
  GROQ_VISION_MODEL=qwen/qwen3.8-27b
7
11
  # Optional comma-separated vision models available on YOUR account; empty by default.
package/server/main.py CHANGED
@@ -41,11 +41,16 @@ logger = logging.getLogger("browser-assistant")
41
41
  load_dotenv(Path(__file__).with_name('.env'))
42
42
 
43
43
  # Setup Groq — multiple API keys for rate-limit rotation
44
- _groq_keys = []
45
- for env_var in ["GROQ_API_KEY", "GROQ_API_KEY_2", "GROQ_API_KEY_3"]:
46
- key = os.getenv(env_var)
47
- if key and key != "your_groq_api_key_here" and key not in _groq_keys:
48
- _groq_keys.append(key)
44
+ def load_groq_keys():
45
+ """Load up to seven distinct configured credentials in stable order."""
46
+ keys = []
47
+ for env_var in ["GROQ_API_KEY", *[f"GROQ_API_KEY_{i}" for i in range(2, 8)]]:
48
+ key = os.getenv(env_var, "").strip()
49
+ if key and key != "your_groq_api_key_here" and key not in keys:
50
+ keys.append(key)
51
+ return keys
52
+
53
+ _groq_keys = load_groq_keys()
49
54
 
50
55
  # Retry rotation is handled below. Disable the SDK's long exponential retry so
51
56
  # a rate-limited key cannot hold up every next question before we try another.
@@ -195,7 +200,7 @@ async def lifespan(_app: FastAPI):
195
200
  client.close()
196
201
 
197
202
 
198
- app = FastAPI(title="Browser Assistant API", version="2.9.41", lifespan=lifespan)
203
+ app = FastAPI(title="Browser Assistant API", version="2.9.42", lifespan=lifespan)
199
204
  install_local_guards(app)
200
205
 
201
206
  @app.exception_handler(HTTPException)