
    phx                     6    S SK r S SKJr  S SKJr  S rS rS rg)    N)pairs_to_dict)CallbacksOptionsc                    U c  U $ UR                  [        R                  R                  5      (       a  0 nUR                  [        R                  R                  5      (       a  U S   R                  S5      OU S   US'   U S   US'   [        U S   5      US'   [        U 5      S:  a  [        U S   5      US	'   U$ UR                  [        R                  R                  5      (       a  U $ / n[        [        U 5      5       H   n UR                  [        X   5      5        M"     U$ ! [         a     UR                  [        X   5      5         MO  f = f)
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]]
r   zutf-8quantization   raw   l2   range)getr   RAWvalueALLOW_DECODINGdecodefloatlenRESP3r   appendint
ValueError)responseoptionsresultis       X/home/james-whalen/.local/lib/python3.13/site-packages/redis/commands/vectorset/utils.pyparse_vemb_resultr      s3    {{#''--.. {{+::@@AA QKw'! 	~
 !uXa[)tx=1#HQK0F7O;;'--3344Os8}%A2c(+./ & 	  2eHK012s   D''&EEc                    U c  U $ UR                  [        R                  R                  5      (       aQ  / nU  HG  n0 n[	        U5      R                  5        H  u  pV[        U5      nXdU'   M     UR                  U5        MI     U$ U $ )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]]
)r   r   
WITHSCORESr   r   itemsr   r   )r   r   r   
level_itemlevel_data_dictkeyr   s          r   parse_vlinks_resultr$   .   s     {{#..4455 #J O+J7==?
e',$ @ MM/* #      c                    U c  U $ [        UR                  [        R                  R                  5      5      n[        UR                  [        R
                  R                  5      5      nU(       a  U(       a  U(       d  U(       a  0 nUR                  [        R                  R                  5      (       a  U nO[        U 5      nUR                  5        H;  u  pgU(       a  [        U5      nOU(       a  [        R                  " U5      OSnXtU'   M=     U$ U(       a  U(       a  [        U 5      n0 nUR                  [        R                  R                  5      (       aG  U R                  5        H1  u  pU
S   b  [        R                  " U
S   5      nOSnU
S   US.XI'   M3     U$ [        XU5       H2  u  pnUb  [        R                  " U5      nOSn[        U5      US.XI'   M4     U$ U $ )a  
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]] - when with_scores is used (without attributes)
- List[Dict[str, Mapping[str, Any]]] - when with_attribs is used (without scores)
- List[Dict[str, Union[Number, Mapping[str, Any]]]] - when with_scores and with_attribs are used

Nr   r   )score
attributes)boolr   r   r   r   WITHATTRIBSr   r   r    r   jsonloadsiterzip)r   r   
withscoreswithattribsresult_dict	resp_dictr#   r   itelemdataattribs_dictr'   attribss                 r   parse_vsim_resultr8   J   s    gkk"2"="="C"CDEJw{{#3#?#?#E#EFGK 	;
{ ;;'--3344 I%h/I#//+JCe-2

5)$ , 	(^;;'--3344&nn.
7&#'::d1g#6L#'L.21g\$R! /  ),BB$W&#'::g#6L#'L.3El,$W! )8  r%   )r+   redis._parsers.helpersr   !redis.commands.vectorset.commandsr   r   r$   r8    r%   r   <module>r<      s     0 >$N88r%   