rohitg00/ai-engineering-from-scratch · error · ValueError
tc.mode
Error message
tc.mode
What it means
Error "tc.mode" thrown in rohitg00/ai-engineering-from-scratch.
Source
Thrown at phases/13-tools-and-protocols/02-function-calling-deep-dive/code/main.py:113
{
"name": tool.name,
"description": tool.description,
"parameters": _gemini_schema(tool.input_schema),
}
]
}
def tool_choice_openai(tc: ToolChoice) -> Any:
if tc.mode == "auto":
return "auto"
if tc.mode == "none":
return "none"
if tc.mode == "required":
return "required"
if tc.mode == "force":
return {"type": "function", "function": {"name": tc.tool_name}}
raise ValueError(tc.mode)
def tool_choice_anthropic(tc: ToolChoice) -> dict:
if tc.mode == "auto":
return {"type": "auto"}
if tc.mode == "none":
return {"type": "none"}
if tc.mode == "required":
return {"type": "any"}
if tc.mode == "force":
return {"type": "tool", "name": tc.tool_name}
raise ValueError(tc.mode)
def tool_choice_gemini(tc: ToolChoice) -> dict:
mode_map = {"auto": "AUTO", "none": "NONE", "required": "ANY"}
if tc.mode in mode_map:
return {"function_calling_config": {"mode": mode_map[tc.mode]}}View on GitHub (pinned to 39ea8a1c6d)
When it happens
Trigger: Thrown at phases/13-tools-and-protocols/02-function-calling-deep-dive/code/main.py:113 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26).
Data as JSON: /api/errors/8d8effe34b9ff2ab.
Report an issue: GitHub.