o
    h                     @   s4   d dl mZ d dlmZ dd Zdd Zdd Zd	S )
    )pairs_to_dict)CallbacksOptionsc              	   K   s   | du r| S | tjjrAi }| tjjr| d dn| d |d< | d |d< t| d |d< t| d	kr?t| d	 |d
< |S | tjjrJ| S g }t	t| D ]}z|
t| |  W qR tyq   |
t| |  Y qRw |S )a  
    Handle VEMB result since the command can returning different result
    structures depending on input options and on quantization type of the vector set.

    Parsing VEMB result into:
    - List[Union[bytes, Union[int, float]]]
    - Dict[str, Union[bytes, str, float]]
    Nr   zutf-8quantization   raw   l2   range)getr   RAWvalueALLOW_DECODINGdecodefloatlenRESP3r
   appendint
ValueError)responseoptionsresulti r   `/var/www/html/optinet_system/venv/lib/python3.10/site-packages/redis/commands/vectorset/utils.pyparse_vemb_result   s.   	r   c                 K   sd   | du r| S | tjjr0g }| D ]}i }t| D ]\}}t|}|||< q|| q|S | S )z
    Handle VLINKS result since the command can be returning different result
    structures depending on input options.
    Parsing VLINKS result into:
    - List[List[str]]
    - List[Dict[str, Number]]
    N)r   r   
WITHSCORESr   r   itemsr   r   )r   r   r   
level_itemlevel_data_dictkeyr   r   r   r   parse_vlinks_result,   s   
r"   c                 K   sL   | du r| S | tjjr$i }t|  D ]\}}t|}|||< q|S | S )z
    Handle VSIM result since the command can be returning different result
    structures depending on input options.
    Parsing VSIM result into:
    - List[List[str]]
    - List[Dict[str, Number]]
    N)r   r   r   r   r   r   r   )r   r   result_dictr!   r   r   r   r   parse_vsim_resultH   s   
r$   N)redis._parsers.helpersr   !redis.commands.vectorset.commandsr   r   r"   r$   r   r   r   r   <module>   s
    '