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:
@@ -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