def _resolve_tool_choice(
    tool_choice: Optional[Union[str, dict]] = None,
    tool_required: bool = False,
) -> Union[str, dict]:
    """
    Resolve the tool choice into a string or a dictionary.

    If the tool_choice is a string that is not in SUPPORTED_TOOL_CHOICES, a dictionary
    representing a function call is returned.

    Args:
        tool_choice: The desired tool choice, which can be a string or a dictionary. Defaults to "auto".

    Returns:
        Either the original tool_choice if valid or a dictionary representing a function call.

    """
    if tool_choice is None:
        tool_choice = "required" if tool_required else "auto"
    if isinstance(tool_choice, str) and tool_choice not in SUPPORTED_TOOL_CHOICES:
        return {"type": "function", "function": {"name": tool_choice}}
    return tool_choice

    Resolve the tool choice into a string or a dictionary.

    If the tool_choice is a string that is not in SUPPORTED_TOOL_CHOICES, a dictionary
    representing a function call is returned.

    Args:
        tool_choice: The desired tool choice, which can be a string or a dictionary. Defaults to "auto".

    Returns:
        Either the original tool_choice if valid or a dictionary representing a function call.

    
llama-index-integrations/llms/llama-index-llms-oci-data-science/llama_index/llms/oci_data_science/utils.py