mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
fix: remove duplicate import and guard empty-string mapping for None tool names
- Remove the duplicate `restore_openai_tool_name_for_user` import in streaming_chunk_builder_utils.py - Only store the sanitized→original name mapping when the original name is non-empty; when `fn["name"]` is None the generated placeholder (e.g. `litellm_unnamed_tool_0`) is kept as-is on the response path instead of being replaced with an empty string Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
14d0252b3b
commit
833b62ca71
2 changed files with 2 additions and 5 deletions
|
|
@ -9,9 +9,6 @@ from litellm.types.llms.openai import (
|
|||
ChatCompletionAssistantContentValue,
|
||||
ChatCompletionAudioDelta,
|
||||
)
|
||||
from litellm.litellm_core_utils.openai_tool_name_mapping import (
|
||||
restore_openai_tool_name_for_user,
|
||||
)
|
||||
from litellm.types.utils import (
|
||||
ChatCompletionAudioResponse,
|
||||
ChatCompletionMessageToolCall,
|
||||
|
|
|
|||
|
|
@ -7918,13 +7918,13 @@ def _maybe_fix_openai_function_tool_name(
|
|||
if tool_type is not None and tool_type != "function":
|
||||
return
|
||||
raw = fn.get("name")
|
||||
raw_original = str(raw) if raw is not None else ""
|
||||
raw_original = str(raw) if raw is not None else None
|
||||
base = _sanitize_openai_function_tool_name(
|
||||
str(raw) if raw is not None else "", index
|
||||
)
|
||||
unique = _make_unique_openai_tool_name(base, used_names)
|
||||
fn["name"] = unique
|
||||
if unique != raw_original:
|
||||
if raw_original and unique != raw_original:
|
||||
store_openai_tool_name_mapping(unique, raw_original)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue