Team Ai
Apppublic

afulara/PythonicRAG-FastAPI-React

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
0likes
prompts.cpython-313.pyc50 linesDownload Raw Back to __pycache__
1�

2ʱ�g�	��*�SSKr"SS5r"SS\5r"SS\5r"SS	\5r"S3S\5r\S:XaS\"S
5r\"\RSSS95 \"S
5r\"\RSSS95 \"\R55 gg)�Nc�&�\rSrSrSrSrSrSrg)�4BasePrompt�c�F�Xl[R"S5Ulg)z�5Initializes the BasePrompt object with a prompt template.6 7:param prompt: A string that can contain placeholders within curly braces8z\{([^}]+)\}N)�prompt�re�compile�_pattern)�selfrs  ځ/Users/aqsa/AI Projects/AIE6 Class Projects/AIE6-DeployPythonicRAG/fastapi-react-app/backend/aimakerspace/openai_utils/prompts.py�__init__�BasePrompt.__init__s�����9�10�>�2��
�c���URRUR5nURR"S0UVs0sHo3UR	US5_M snD6$s snf)z�11Formats the prompt string using the keyword arguments provided.12 13:param kwargs: The values to substitute into the prompt string14:return: The formatted prompt string15��)r16�findallr�format�get)r�kwargs�matches�matchs    r�
format_prompt�BasePrompt.format_promptsT���-�-�'�'����4���{�{�!�!�X�w�$W�w�e�F�J�J�u�b�,A�%A�w�$W�X�X��$Ws�A#c�L�URRUR5$)zf17Gets the list of input variable names from the prompt string.18 19:return: List of input variable names20)r21rr)rs r�get_input_variables�BasePrompt.get_input_variabless���}�}�$�$�T�[�[�1�1r)r22rN)�__name__�23__module__�__qualname__�__firstlineno__r
rr�__static_attributes__rrrrrs��3�Y�2rrc�:^�\rSrSrS\4U4SjjrSSjrSrU=r$)�24RolePrompt�!�rolec�0>�[TU]U5 X lg)z�25Initializes the RolePrompt object with a prompt template and a role.26 27:param prompt: A string that can contain placeholders within curly braces28:param role: The role for the message ('system', 'user', or 'assistant')29N)�superr
r&)rrr&�	__class__s   �rr
�RolePrompt.__init__"s���	���� ��	rc��U(aURUR"S0UD6S.$URURS.$)z�30Creates a message dictionary with a role and a formatted message.31 32:param kwargs: The values to substitute into the prompt string33:return: Dictionary containing the role and the formatted message34)r&�contentr)r&rr)rrrs   r�create_message�RolePrompt.create_message,s7��� �I�I�$�2D�2D�2N�v�2N�O�O��	�	�d�k�k�:�:r)r&)T)	rrr r!�strr
r-r"�
__classcell__�r)s@rr$r$!s����S��35;�36;rr$c�0^�\rSrSrS\4U4SjjrSrU=r$)�SystemRolePrompt�9rc�&>�[TU]US5 g)N�system�r(r
�rrr)s  �rr
�SystemRolePrompt.__init__:s���
�����*rr�rrr r!r/r
r"r0r1s@rr3r39s���+�s�+�+rr3c�0^�\rSrSrS\4U4SjjrSrU=r$)�UserRolePrompt�>rc�&>�[TU]US5 g)N�userr7r8s  �rr
�UserRolePrompt.__init__?s���
�����(rrr:r1s@rr<r<>s���)�s�)�)rr<c�0^�\rSrSrS\4U4SjjrSrU=r$)�AssistantRolePrompt�Crc�&>�[TU]US5 g)N�	assistantr7r8s  �rr
�AssistantRolePrompt.__init__Ds���
�����-rrr:r1s@rrBrBCs���.�s�.�.rrB�__main__z%Hello {name}, you are {age} years old�John�)�name�age)rrr$r3r<rBrr�printrr-rrrr�<module>rMs���	�2�2�:;��;�0+�z�+�37)�Z�)�38.�*�.�39�z��
�?�
@�F�	�&�40�41�F��42�433�4�
�E�
F�F�	�&�44�45�V��46�474�5�	�&�48$�49$�50&�'�
r