refactor(llm_models): 优化并发请求的返回值处理
修改了`execute_concurrently`的返回逻辑,将其解包以分别返回`content`和包含`reasoning_content`, `model_name`, `tool_calls`的元组。这使得调用方能更清晰地处理并发请求的结果。
This commit is contained in:
committed by
Windpicker-owo
parent
5516c43fe3
commit
ed4d7e8e61
@@ -261,7 +261,7 @@ class LLMRequest:
|
|||||||
try:
|
try:
|
||||||
# 为 _execute_single_request 传递参数时,将 raise_when_empty 设为 False,
|
# 为 _execute_single_request 传递参数时,将 raise_when_empty 设为 False,
|
||||||
# 这样单个请求失败时不会立即抛出异常,而是由 gather 统一处理
|
# 这样单个请求失败时不会立即抛出异常,而是由 gather 统一处理
|
||||||
return await execute_concurrently(
|
content, (reasoning_content, model_name, tool_calls) = await execute_concurrently(
|
||||||
self._execute_single_request,
|
self._execute_single_request,
|
||||||
concurrency_count,
|
concurrency_count,
|
||||||
prompt,
|
prompt,
|
||||||
@@ -270,6 +270,7 @@ class LLMRequest:
|
|||||||
tools,
|
tools,
|
||||||
raise_when_empty=False,
|
raise_when_empty=False,
|
||||||
)
|
)
|
||||||
|
return content, (reasoning_content, model_name, tool_calls)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"所有 {concurrency_count} 个并发请求都失败了: {e}")
|
logger.error(f"所有 {concurrency_count} 个并发请求都失败了: {e}")
|
||||||
if raise_when_empty:
|
if raise_when_empty:
|
||||||
|
|||||||
Reference in New Issue
Block a user