| Server IP : 157.230.181.24 / Your IP : 216.73.217.11 Web Server : Apache/2.4.58 (Ubuntu) System : Linux conductive 6.8.0-117-generic #117-Ubuntu SMP PREEMPT_DYNAMIC Tue May 5 19:26:24 UTC 2026 x86_64 User : ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /proc/self/root/opt/aim-bots/__pycache__/ |
Upload File : |
�
��Yj% � �l � d Z ddlmZ ddlZddlZddlZddlmZ ddlm Z ddl
mZ d
d�Z G d� d � Z
y)u9 Fuzzy retrieval over archived AIM user→assistant pairs.� )�annotationsN)�SequenceMatcher)�Path)�is_followupc � � t j dd| j � j � � } t j dd| � S )Nz\s+� z
[^\w\s!?=.\-]� )�re�sub�lower�strip)�texts � /opt/aim-bots/reply_retriever.py� normalizer s7 � �
�6�6�&�#�t�z�z�|�1�1�3�4�D�
�6�6�"�B��-�-� c �R � e Zd ZdZdd d�Zd
dd�Zdd�Z d
dd�Zddd�Zy)�ReplyRetrieverzFMap incoming lines to archived replies when the match is close enough.c � � || _ |j � sg | _ g | _ y t j
|dd�� 5 }t
j |� | _ d d d � | j D �cg c]6 }|j d� s�|j d� s�'t |d � |f��8 c}| _ y # 1 sw Y �[xY wc c}w )N�rtzutf-8)�encoding�user� assistant)
� min_ratio�exists�pairs�index�gzip�open�json�load�getr )�self�
pairs_pathr �fh�ps r �__init__zReplyRetriever.__init__ s� � �"���� � �"�%'�D�J�13�D�J��
�Y�Y�z�4�'�
:� '�b����2��D�J� '�9=���l�A�q�u�u�V�}�YZ�Y^�Y^�_j�Yk�y��6��+�Q�/�l��
� '� '��ls �B4�0C �C �C �4B=c �v � t |� }|r| j sg S g }t |� }| j D ]k \ }}t t |� |z
� t d|dz � kD r�.t d ||� j
� }|| j k\ s�Y|j ||f� �m |j d� �� |d | S )N� � c � � | d S �Nr � ��xs r �<lambda>z&ReplyRetriever.match.<locals>.<lambda>, � � �1�Q�4�%� r ��key)
r r �len�abs�maxr �ratior �append�sort) r"