ptp_query_engine.cpython-311.pyc•19 kB
�
�|hKE � � � d Z ddlZddlZddlZddlmZmZmZmZm Z ddl
m
Z
mZ ej e
� � Z G d� d� � ZdS )z@
PTP Query Engine - Natural language processing for PTP queries
� N)�Dict�List�Optional�Any�Tuple)�datetime� timedeltac �� � e Zd ZdZd� Zddededeeef fd�Zdedefd�Z dede
e fd �Zdedeeef fd
�Zdeeef deeef defd
�Z
deeef defd�Zdeeef defd�Zdeeef defd�Zdeeef defd�Zdeeef defd�Zdeeef defd�Zdeeef defd�Zdeeef defd�Zdeeef defd�Zddedee fd�ZdS )�PTPQueryEnginez1Natural language query engine for PTP informationc �z � g d�g d�g d�g d�g d�g d�g d�g d�g d �g d
�d�
| _ g d�g d
�g d�g d�d�| _ d S )N)zwhat is the current grandmasterzwho is the grandmasterzshow grandmasterzgrandmaster statusz
current gm)zshow ptpconfig parameterszptp configuration� ptpconfigzconfiguration parameterszshow config)zcheck for sync losszsync statuszsynchronization statuszis it syncedzsync health)zclock hierarchyzshow clock hierarchyzclock topologyzclock structure)zoffset trendzget offset trendzoffset analysiszfrequency offset)z
bmca statezbest master clockzmaster clock algorithmzbmca status)zclockclass changezclock class�
clockclasszclass change)zsearch logsz
log searchzfind in logszlog analysis)zhealth checkz
ptp healthz
system health�diagnostics)zitu compliancez
g\.8275\.1zitu-tzcompliance check)
�grandmaster�
configuration�sync_status�clock_hierarchy�offset_trend�
bmca_state�clock_class�logs_search�health_check�itu_compliance)z last hourz past hourzin the last hour)zlast dayzpast dayzin the last day� yesterday)z last weekz past weekzin the last week)�"last (\d+) (minutes?|hours?|days?)z"past (\d+) (minutes?|hours?|days?)z!(\d+) (minutes?|hours?|days?) ago)� last_hour�last_day� last_week�custom_time)�query_patterns�
time_patterns)�selfs �</home/aputtur/Ai Projects/ptp-mcp-server/ptp_query_engine.py�__init__zPTPQueryEngine.__init__ s� � �� � �� � �� � � � � �� � �� � �� � �� � �� � �� � �u@
� @
���H� � �
� � �� � �
� � �#
�
����� N�question�context�returnc �$ � |� � � � � � }| � |� � }| � |� � }| � |� � }|||||t j � � � � � d�S )z3Parse natural language query into structured format)�original_questionr'