
    &`iM                         d dl mZmZmZ deeef         deeeef                  deeef         fdZdeeef         deeef         deeef         fdZd	S )
    )AnyDictOptionaldefaultsuser_deployment_configreturnc                     |r.d|v r*|                                  } |                     dd           t          | |pi           S )a  Apply defaults and merge with user-provided deployment config.

    If the user has explicitly set 'num_replicas' in their deployment config,
    we remove 'autoscaling_config' from the defaults since Ray Serve
    does not allow both to be set simultaneously. Then merges the defaults
    with the user config.

    Args:
        defaults: The default deployment options dictionary.
        user_deployment_config: The user-provided deployment configuration.

    Returns:
        The merged deployment options with conflicts resolved.
    num_replicasautoscaling_configN)copypopdeep_merge_dicts)r   r   s     w/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/llm/_internal/common/dict_utils.py*maybe_apply_llm_deployment_config_defaultsr      sO    $  1.4J"J"J==??)4000H&<&BCCC    baseoverridec                    |                                  }|                                D ]X\  }}||v rJt          ||         t                    r/t          |t                    rt	          ||         |          ||<   S|||<   Y|S )a  
    Merge two dictionaries hierarchically, creating a new dictionary without modifying inputs.

    For each key:
    - If the key exists in both dicts and both values are dicts, recursively merge them
    - Otherwise, the value from override takes precedence

    Args:
        base: The base dictionary
        override: The dictionary with values that should override the base

    Returns:
        A new merged dictionary

    Example:
        >>> base = {"a": 1, "b": {"c": 2, "d": 3}}
        >>> override = {"b": {"c": 10}, "e": 5}
        >>> result = deep_merge_dicts(base, override)
        >>> result
        {'a': 1, 'b': {'c': 10, 'd': 3}, 'e': 5}
    )r   items
isinstancedictr   )r   r   resultkeyvalues        r   r   r      s    , YY[[Fnn&&    
U&==ZsT::=z%QU?V?V=*6#;>>F3KK  F3KKMr   N)typingr   r   r   strr   r    r   r   <module>r      s    & & & & & & & & & &D38nD$T#s(^4D 
#s(^D D D D0 4S>  T#s(^  SRUX            r   