File: //home/arjun/projects/buyercall/buyercall/blueprints/chat/__pycache__/endpoints.cpython-310.pyc
o
we� � @ sP d dl mZ d dlmZmZ d dlZd dlmZmZm Z d dl
mZ d dlm
Z
d dlmZ d dlmZ d d lmZ d d
lmZmZ d dlmZ d dlmZ d d
lmZ d dlmZ ededd�Ze� e�Z!d*dd�Z"d+dd�Z#e
dd� �Z$e
dd� �Z%e
dd� �Z&e
dd� �Z'e
dd� �Z(d d!� Z)d"d#� Z*d$d%� Z+e
d&d'� �Z,e
d(d)� �Z-dS ),� )�uuid4)�datetime� timedeltaN)� Blueprint�request�current_app)�current_user)�authenticate)�api_jsonify)�Widget)� es_client)�insert_data_by_index�search_data)�ask_rasa)�flask_environment)�get_available_agent_ids)�Q�chat_apiz /api/chat)�
url_prefixc O s� | rC|sC| � d�dkr=d| v r!t| �dkr| ddd�S dddd�S d | v r7t| �d
kr1d| dd�S dddd�S dddd�S dddd�S | s�|r�|� d�dkr�d|v rdt| �dkr^|ddd�S dddd�S d |v rzt| �d
krtd|dd�S dddd�S dddd�S dddd�S | r�|r�| � d�dkr�|� d�dkr�d| v r�| n|}d | v r�| n|}d|v r�d |v r�t|�dkr�t|�d
kr�||dd�S dddd�S dddd�S dddd�S dddd�S )a!
This method validates the received from and to of chat and finds who is user and agent.
user's id contains the string 'USER' and agent's id contains the string 'AGENT'.
:chat_from param: str
:chat_to param: str
:return dict: {user: str, agent: str, success: bool}
�-�
�USER�N NT)�user�agent�successF�AGENT�O )�count�len)� chat_from�chat_to�args�kwargsr r � r$ �E/home/arjun/projects/buyercall/buyercall/blueprints/chat/endpoints.py�validate_from_to sF r&