binary-husky/gpt_academic · error · Exception
Response {i} is None
Error message
Response {i} is None What it means
QueryAnalyzer fans out several prompts through request_gpt_model_multi... and then reads responses at odd indices (responses[i*2+1] — the assistant turn interleaved with user turns). If such an entry is None, the LLM call for that prompt produced no output and the analyzer raises Exception('Response {i} is None'). None here means the multi-request bridge returned a placeholder for a failed/skipped generation, not that the list is malformed.
Source
Thrown at crazy_functions/review_fns/query_analyzer.py:182
# 使用同步方式调用LLM
responses = yield from request_gpt(
inputs_array=prompts,
inputs_show_user_array=show_messages,
llm_kwargs=new_llm_kwargs,
chatbot=chatbot,
history_array=[[] for _ in prompts],
sys_prompt_array=sys_prompts,
max_workers=5
)
# 从收集的响应中提取我们需要的内容
extracted_responses = []
for i in range(len(prompts)):
if (i * 2 + 1) < len(responses):
response = responses[i * 2 + 1]
if response is None:
raise Exception(f"Response {i} is None")
if not isinstance(response, str):
try:
response = str(response)
except:
raise Exception(f"Cannot convert response {i} to string")
extracted_responses.append(response)
else:
raise Exception(f"未收到第 {i + 1} 个响应")
# 解析基本信息
query_type = self._extract_tag(extracted_responses[self.BASIC_QUERY_INDEX], "query_type")
if not query_type:
print(
f"Debug - Failed to extract query_type. Response was: {extracted_responses[self.BASIC_QUERY_INDEX]}")
raise Exception("无法提取query_type标签内容")
query_type = query_type.lower()
main_topic = self._extract_tag(extracted_responses[self.BASIC_QUERY_INDEX], "main_topic")View on GitHub (pinned to d6bde0fa54)
Solutions
- Retry the whole analysis call — transient API failures usually succeed on a second run.
- Check the LLM backend logs/config (API key, rate limits, model name) if the same index is None every time.
- Reduce max_workers concurrency (5 parallel requests) if rate limiting is the cause.
- Report which prompt index failed (the {i} in the message maps to prompts[i]) to identify a poison prompt.
Defensive patterns
Strategy: retry
Type guard
def has_all_responses(responses: list, prompt_count: int) -> bool:
return (
len(responses) >= prompt_count * 2
and all(responses[i * 2 + 1] is not None for i in range(prompt_count))
) Try / catch
try:
result = analyzer.analyze(query)
except Exception as e:
if 'is None' in str(e): # transient LLM worker failure
result = analyzer.analyze(query) # one retry
else:
raise Prevention
- Keep max_workers low enough to stay under the provider's concurrency/rate limits.
- Retry once on None-response errors before surfacing them to users.
- Monitor API quota — mid-batch exhaustion is the most common cause of None turns.
When it happens
Trigger: One of the parallel LLM requests fails or is dropped (API error swallowed by the bridge, empty completion, worker exception) while others succeed, leaving responses[k] = None at the assistant slot; intermittent network/API errors during the 5-worker fan-out.
Common situations: API key quota/rate limit hit mid-batch so some workers return None; model endpoint returning empty completion for one prompt; timeouts in the multi-thread bridge; misconfigured LLM_MODEL that fails only on certain prompt shapes.
Related errors
- 未收到第 {i + 1} 个响应
- 未收到第 {i + 1} 个响应
- Cannot convert response {i} to string
- 无法提取query_type标签内容
- 分析查询失败: {str(e)}
AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14).
Data as JSON: /api/errors/63c279b98ed168e2.
Report an issue: GitHub.