infiniflow/ragflow · error · ValueError

Invalid response from BGPT

Error message

Invalid response from BGPT

What it means

Error "Invalid response from BGPT" thrown in infiniflow/ragflow.

Source

Thrown at agent/tools/bgpt.py:103

        payload = {"query": query.strip(), "num_results": self._param.top_n}
        if self._param.api_key:
            payload["api_key"] = self._param.api_key
        if self._param.days_back:
            payload["days_back"] = self._param.days_back

        last_e = ""
        for _ in range(self._param.max_retries + 1):
            if self.check_if_canceled("BGPT processing"):
                return

            try:
                response = requests.post(BGPT_SEARCH_URL, json=payload, timeout=25)
                response.raise_for_status()
                data = response.json()

                if not data or not isinstance(data, dict):
                    raise ValueError("Invalid response from BGPT")

                results = data.get("results", [])
                if not isinstance(results, list):
                    raise ValueError("Invalid results format from BGPT")

                if self.check_if_canceled("BGPT processing"):
                    return

                self._retrieve_chunks(
                    results,
                    get_title=lambda paper: paper.get("title") or "Untitled",
                    get_url=lambda paper: paper.get("url") or paper.get("doi") or "",
                    get_content=lambda paper: self._format_bgpt_paper(paper),
                )
                self.set_output("json", results)
                return self.output("formalized_content")

            except requests.HTTPError as e:

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Check that the BGPT endpoint returned a well-formed response body.
  2. Verify BGPT_API_KEY and endpoint configuration, then retry.

Example fix

resp = requests.post(url, json=payload, timeout=30)
if not resp.ok:
    raise Exception(f'Invalid response from BGPT: {resp.status_code}')
return resp.json()

When it happens

Trigger: Thrown at agent/tools/bgpt.py:103 when the library encounters an invalid state.

Common situations: BGPT service returns an error status, an empty body, or non-JSON content; validating the HTTP status and payload shape before parsing prevents this error.


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/864e12b6c289506e. Report an issue: GitHub.