We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug 在代码实现中,for 循环用于最多尝试 10 次调用 API,但 return 在第一次调用时就被触发,导致循环未完成,无法进行多次尝试。
To Reproduce Steps to reproduce the behavior:
Go to https://github.com/assafelovic/gpt-researcher/blob/master/gpt_researcher/utils/llm.py
`for _ in range(10): # maximum of 10 attempts response = await provider.get_chat_response( messages, stream, websocket )
if cost_callback: llm_costs = estimate_llm_cost(str(messages), response) cost_callback(llm_costs)
return response
logging.error(f"Failed to get response from {llm_provider} API") raise RuntimeError(f"Failed to get response from {llm_provider} API")`
注意到 return response 在第一次循环时直接退出了循环。 重现尝试的逻辑场景:即使 API 第一次调用失败,循环没有继续尝试,而是跳过后续逻辑。
Expected behavior A clear and concise description of what you expected to happen. 循环应最多尝试 10 次调用 API,而不是在第一次调用后直接返回。期望逻辑如下:
如果前几次调用失败,循环会继续,直到达到最大尝试次数。 如果成功,返回 response。 如果所有尝试都失败,记录日志并引发异常。
The text was updated successfully, but these errors were encountered:
Welcome @6open
Green light for the PR
10 seems like a lot - how about 3 retries?
Sorry, something went wrong.
No branches or pull requests
Describe the bug
在代码实现中,for 循环用于最多尝试 10 次调用 API,但 return 在第一次调用时就被触发,导致循环未完成,无法进行多次尝试。
To Reproduce
Steps to reproduce the behavior:
Go to https://github.com/assafelovic/gpt-researcher/blob/master/gpt_researcher/utils/llm.py
`for _ in range(10): # maximum of 10 attempts
response = await provider.get_chat_response(
messages, stream, websocket
)
if cost_callback:
llm_costs = estimate_llm_cost(str(messages), response)
cost_callback(llm_costs)
return response
logging.error(f"Failed to get response from {llm_provider} API")
raise RuntimeError(f"Failed to get response from {llm_provider} API")`
注意到 return response 在第一次循环时直接退出了循环。
重现尝试的逻辑场景:即使 API 第一次调用失败,循环没有继续尝试,而是跳过后续逻辑。
Expected behavior
A clear and concise description of what you expected to happen.
循环应最多尝试 10 次调用 API,而不是在第一次调用后直接返回。期望逻辑如下:
如果前几次调用失败,循环会继续,直到达到最大尝试次数。
如果成功,返回 response。
如果所有尝试都失败,记录日志并引发异常。
The text was updated successfully, but these errors were encountered: