browser-assistant 2.9.35 → 2.9.36
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/journal.py +4 -1
- package/server/main.py +17 -7
package/extension/manifest.json
CHANGED
package/package.json
CHANGED
package/server/journal.py
CHANGED
|
@@ -99,7 +99,10 @@ def register_journal(app, cloud, local):
|
|
|
99
99
|
except Exception:
|
|
100
100
|
raw = await local(messages, temperature=0.2)
|
|
101
101
|
except Exception as exc:
|
|
102
|
-
raise HTTPException(
|
|
102
|
+
raise HTTPException(
|
|
103
|
+
503, 'Journal generation could not get a response from Groq or local Ollama. '
|
|
104
|
+
'Try again shortly. If it keeps failing, check your Groq quota or start Ollama.'
|
|
105
|
+
) from exc
|
|
103
106
|
try:
|
|
104
107
|
raw = re.sub(r'^```(?:json)?\s*|\s*```$', '', raw.strip())
|
|
105
108
|
sections, count = validate_sections(json.loads(raw))
|
package/server/main.py
CHANGED
|
@@ -195,7 +195,7 @@ async def lifespan(_app: FastAPI):
|
|
|
195
195
|
client.close()
|
|
196
196
|
|
|
197
197
|
|
|
198
|
-
app = FastAPI(title="Browser Assistant API", version="2.9.
|
|
198
|
+
app = FastAPI(title="Browser Assistant API", version="2.9.36", lifespan=lifespan)
|
|
199
199
|
install_local_guards(app)
|
|
200
200
|
|
|
201
201
|
@app.exception_handler(HTTPException)
|
|
@@ -429,7 +429,7 @@ def save_automation_history(entry: AutomationHistoryEntry):
|
|
|
429
429
|
|
|
430
430
|
# ── AI providers ──────────────────────────────────────────────────────────────
|
|
431
431
|
|
|
432
|
-
async def try_groq(messages: list, model: str = None, temperature: float = 0.0, _token_limit: int = GROQ_COMPLETION_TOKEN_LIMIT, _review: bool = False) -> str:
|
|
432
|
+
async def try_groq(messages: list, model: str = None, temperature: float = 0.0, _token_limit: int = GROQ_COMPLETION_TOKEN_LIMIT, _review: bool = False, *, structured: bool = False) -> str:
|
|
433
433
|
"""Call Groq with automatic API key rotation on rate limit (429)."""
|
|
434
434
|
global _groq_disabled_until, _groq_key_index
|
|
435
435
|
if time.monotonic() < _groq_disabled_until:
|
|
@@ -441,9 +441,8 @@ async def try_groq(messages: list, model: str = None, temperature: float = 0.0,
|
|
|
441
441
|
use_model = model or GROQ_TEXT_MODEL
|
|
442
442
|
loop = asyncio.get_running_loop()
|
|
443
443
|
review_options = {}
|
|
444
|
-
if _review:
|
|
445
|
-
#
|
|
446
|
-
# bounded so GPT-OSS leaves room for its final JSON verdict.
|
|
444
|
+
if _review or structured:
|
|
445
|
+
# Keep reasoning bounded so GPT-OSS leaves room for the final JSON.
|
|
447
446
|
review_options['response_format'] = {'type': 'json_object'}
|
|
448
447
|
if use_model in {'openai/gpt-oss-20b', 'openai/gpt-oss-120b'}:
|
|
449
448
|
review_options['reasoning_effort'] = 'low'
|
|
@@ -475,7 +474,7 @@ async def try_groq(messages: list, model: str = None, temperature: float = 0.0,
|
|
|
475
474
|
if getattr(choice, "finish_reason", None) == "length":
|
|
476
475
|
if _token_limit < GROQ_RETRY_TOKEN_LIMIT:
|
|
477
476
|
logger.warning(f"{use_model} reached {_token_limit} tokens; retrying once with {GROQ_RETRY_TOKEN_LIMIT}")
|
|
478
|
-
return await try_groq(messages, model=use_model, temperature=temperature, _token_limit=GROQ_RETRY_TOKEN_LIMIT, _review=_review)
|
|
477
|
+
return await try_groq(messages, model=use_model, temperature=temperature, _token_limit=GROQ_RETRY_TOKEN_LIMIT, _review=_review, structured=structured)
|
|
479
478
|
raise RuntimeError(f"{use_model} stopped at the output token limit")
|
|
480
479
|
content = choice.message.content or ""
|
|
481
480
|
if not content.strip():
|
|
@@ -550,6 +549,17 @@ TEXT_MODELS = list(dict.fromkeys([
|
|
|
550
549
|
"openai/gpt-oss-20b",
|
|
551
550
|
]))
|
|
552
551
|
|
|
552
|
+
|
|
553
|
+
async def try_journal_cloud(messages: list, temperature: float = 0.2) -> str:
|
|
554
|
+
for model in TEXT_MODELS:
|
|
555
|
+
if not _groq_clients or time.monotonic() < _groq_disabled_until:
|
|
556
|
+
break
|
|
557
|
+
try:
|
|
558
|
+
return await try_groq(messages, model=model, temperature=temperature, structured=True)
|
|
559
|
+
except Exception as exc:
|
|
560
|
+
logger.warning("Journal model %s failed (%s); trying the next provider.", model, type(exc).__name__)
|
|
561
|
+
raise RuntimeError("No Groq journal model responded.")
|
|
562
|
+
|
|
553
563
|
# Vision model fallback chain
|
|
554
564
|
VISION_MODELS = list(dict.fromkeys([
|
|
555
565
|
GROQ_VISION_MODEL,
|
|
@@ -2069,7 +2079,7 @@ def normalize_vision_results(raw: str) -> str:
|
|
|
2069
2079
|
|
|
2070
2080
|
|
|
2071
2081
|
from journal import register_journal, load_syllabus
|
|
2072
|
-
register_journal(app,
|
|
2082
|
+
register_journal(app, try_journal_cloud, try_ollama)
|
|
2073
2083
|
|
|
2074
2084
|
if __name__ == "__main__":
|
|
2075
2085
|
# The extension talks to this API through its background worker. Binding to
|