M8-T4: Shim liefert nur gefetchte Seiten (>100 chars raw_content) — gptr-Scraper-Crash umgangen; RETRIEVERS zusaetzlich gesetzt
Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -235,3 +235,11 @@ Internet → NPM (CT 103, 443) → auth_request-Subrequest an oauth2-proxy
|
||||
`raw_content` mit vollem Seiten-Text (>100 chars) — dann scrapt
|
||||
gpt-researcher nicht selbst. `SHIM_MAX_RESULTS=8`, Fetch-Cap 200k/Seite,
|
||||
Timeout 10 s. Verifiziert: shim count 8 mit Seiteninhalt.
|
||||
|
||||
- **Befund 20.11. (weiterhin 0 Quellen):** Retriever ok (142 results via
|
||||
shim), aber gpt-researcher scrapt trotzdem und crasht am kaputten Scraper
|
||||
(`Error processing None ... endswith`, `Scraped data size: 0`). Fix im Shim:
|
||||
nur erfolgreich gefetchte Seiten (>100 chars raw_content) werden
|
||||
durchgereicht — dann nutzt gpt-researcher raw_content direkt und scrapt
|
||||
nicht selbst. `RETRIEVERS` (plural) wird zusätzlich gesetzt (v3.8 liest
|
||||
`RETRIEVER`, neuere Pfade offenbar plural).
|
||||
|
||||
@@ -56,6 +56,7 @@ gpt_researcher_env:
|
||||
SMART_LLM: "openai:{{ gpt_researcher_engine_model_id }}"
|
||||
STRATEGIC_LLM: "openai:{{ gpt_researcher_engine_model_id }}"
|
||||
RETRIEVER: custom
|
||||
RETRIEVERS: custom
|
||||
RETRIEVER_ENDPOINT: http://gptr-searxng-shim:8099/
|
||||
LLM_TIMEOUT: "600"
|
||||
LOGGING_LEVEL: INFO
|
||||
|
||||
@@ -59,12 +59,20 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self.wfile.write(json.dumps({"error": str(e)}).encode())
|
||||
return
|
||||
out = []
|
||||
for r in data.get("results", [])[:MAX_RESULTS]:
|
||||
for r in data.get("results", []):
|
||||
u = r.get("url", "")
|
||||
if not u:
|
||||
if not u or not isinstance(u, str):
|
||||
continue
|
||||
content = fetch_text(u)
|
||||
# only pass pages we actually fetched: raw_content > 100 chars
|
||||
# makes gpt-researcher skip its own (broken-in-image) scraper;
|
||||
# short/empty content would trigger the scraper crash
|
||||
# ("Error processing None ... endswith", Scraped 0 pages)
|
||||
if len(content) <= 100:
|
||||
continue
|
||||
content = fetch_text(u) or (r.get("content") or "")
|
||||
out.append({"url": u, "raw_content": content})
|
||||
if len(out) >= MAX_RESULTS:
|
||||
break
|
||||
body = json.dumps(out).encode()
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
|
||||
Reference in New Issue
Block a user