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