Skip to main content
Glama
prompt_templates.cpython-313.pyc8.76 kB
� �:i'����SrSSKJr SSKJrJrJr SSKJrJ r SSK r "SS\5r "SS 5r \ "5r SS \S \S \\S \\\S\\S\\\S\\S\4Sjjrg)z� Enhanced prompt templating system for Delia MCP server. Provides structured prompt templates with JSON schema integration and task-specific optimizations. �)�Template)�Dict�Any�Optional)� BaseModel�FieldNc���\rSrSr%Sr\"SSS9r\\S'\"SSS9r \\S'\"S S S9r \ \\S '\"\ S S 9r \ \ \\S'\"S SS9r\ \\S'\"\ SS 9r\ \ \\S'\"S SS9r\ \\S'Srg )� TaskContext� z&Structured context for task execution..z,Type of task (quick, generate, review, etc.))� description� task_typezMain content to process�contentNz"Programming language if applicable�languagezCode symbols to focus on)�default_factoryr �symbolszFile path if applicable� file_pathzRelated files for context� context_fileszAdditional user instructions�user_instructions�)�__name__� __module__� __qualname__�__firstlineno__�__doc__rr �str�__annotations__rrr�listrrrr�__static_attributes__r��'/home/dan/git/delia/prompt_templates.pyr r s���0��3�,Z�[�I�s�[���*C�D�G�S�D�#�D�6Z�[�H�h�s�m�[�#(��Ke�#f�G�X�d�3�i� �f�$�T�7P�Q�I�x��}�Q�).�t�Ql�)m�M�8�D��I�&�m�',�T�?]�'^��x��}�^rr c�\�\rSrSrSrSrS\\\44Sjr S\ S\4Sjr S\ \4Sjr S rg ) �PromptTemplateManager�z=Manages structured prompt templates for different task types.c�.�UR5Ulg)N)�_load_templates� templates��selfs r �__init__�PromptTemplateManager.__init__s���-�-�/��r�returnc �(�[SR55[SR55[SR55[SR55[SR55[SR55S.$)z/Load Jinja2 templates for different task types.aw You are a helpful AI assistant. Answer the following question or request concisely and accurately. Context: {% if context_files %} Related files: {{ context_files|join(', ') }} {% endif %} {% if language %} Language: {{ language }} {% endif %} Request: {{ content }} {% if symbols %} Focus areas: {{ symbols|join(', ') }} {% endif %} Provide a direct, helpful response. a You are an expert {{ language }} developer. Generate high-quality code based on the following requirements. Context: {% if file_path %} File: {{ file_path }} {% endif %} {% if context_files %} Related files: {{ context_files|join(', ') }} {% endif %} {% if symbols %} Symbols to consider: {{ symbols|join(', ') }} {% endif %} Requirements: {{ content }} {% if user_instructions %} Additional instructions: {{ user_instructions }} {% endif %} Generate complete, working {{ language }} code with proper error handling and documentation. a� You are a senior {{ language }} code reviewer. Analyze the following code for quality, correctness, and best practices. Code to review: ``` {{ content }} ``` {% if file_path %} File: {{ file_path }} {% endif %} {% if context_files %} Related context files: {{ context_files|join(', ') }} {% endif %} Review criteria: - Code correctness and logic - Performance considerations - Security vulnerabilities - Code style and readability - Best practices compliance - Potential improvements {% if symbols %} Key symbols to focus on: {{ symbols|join(', ') }} {% endif %} Provide specific, actionable feedback with severity levels (Critical/Major/Minor). a� You are a technical analyst specializing in {{ language }} code analysis. Code to analyze: ``` {{ content }} ``` {% if file_path %} File location: {{ file_path }} {% endif %} {% if context_files %} Related files for context: {{ context_files|join(', ') }} {% endif %} Analysis objectives: - Understand the code's purpose and functionality - Identify key algorithms and data structures - Assess code complexity and maintainability - Find potential bugs or issues - Suggest improvements and optimizations {% if symbols %} Focus on these symbols: {{ symbols|join(', ') }} {% endif %} {% if user_instructions %} Specific analysis requirements: {{ user_instructions }} {% endif %} Provide a comprehensive analysis with specific findings and recommendations. a" You are an expert software architect. Create a detailed implementation plan for the following requirements. Project requirements: {{ content }} {% if language %} Primary language: {{ language }} {% endif %} {% if file_path %} Target file: {{ file_path }} {% endif %} {% if context_files %} Existing codebase: {{ context_files|join(', ') }} {% endif %} Planning considerations: 1. Architecture and design decisions 2. Implementation steps and phases 3. Dependencies and prerequisites 4. Testing strategy 5. Potential challenges and mitigations 6. Timeline and milestones {% if symbols %} Key components to consider: {{ symbols|join(', ') }} {% endif %} {% if user_instructions %} Additional constraints: {{ user_instructions }} {% endif %} Provide a structured plan with clear, actionable steps. a� You are a technical lead conducting a thorough code review and critique. Code under review: ``` {{ content }} ``` {% if file_path %} Location: {{ file_path }} {% endif %} {% if context_files %} Codebase context: {{ context_files|join(', ') }} {% endif %} Critique dimensions: - Architectural soundness - Code quality and maintainability - Performance implications - Security considerations - Scalability potential - Testing adequacy - Documentation quality {% if symbols %} Critical symbols to evaluate: {{ symbols|join(', ') }} {% endif %} {% if user_instructions %} Review focus areas: {{ user_instructions }} {% endif %} Provide a balanced critique with strengths, weaknesses, and prioritized improvement recommendations. )�quick�generate�review�analyze�plan�critique)r�stripr's r r%�%PromptTemplateManager._load_templatess�����$ �E�G�% �(!�"�* �E�G�+ �.� �8 �E�G�9 �< �!�> �E�G�? �B� �@ �E�G�A  �D!�!"�B �E�G�C! �[o �o r� task_contextc��URRURURS5nUR5nUR"S0UD6$)z:Render a structured prompt using the appropriate template.r-r)r&�getr � model_dump�render)r(r5�template� context_dicts r � render_prompt�#PromptTemplateManager.render_prompt�sI���>�>�%�%�l�&<�&<�d�n�n�W�>U�V��$�.�.�0� ����.��.�.rc�H�[URR55$)z%Get list of available template types.)rr&�keysr's r �get_available_templates�-PromptTemplateManager.get_available_templates�s���D�N�N�'�'�)�*�*r)r&N)rrrrrr)rrrr%r r<rr@rrrr r"r"sE��G�0�q ��c�8�m�!4�q �f/�+�/�#�/�+��c��+rr"r rrrrrrr+c �n�[UUUU=(d /UU=(d /US9n[RU5$)a� Create a structured prompt using the template system. Args: task_type: Type of task (quick, generate, review, analyze, plan, critique) content: Main content to process language: Programming language if applicable symbols: Code symbols to focus on file_path: File path if applicable context_files: Related files for context user_instructions: Additional user instructions Returns: Structured prompt string optimized for the task type )r rrrrrr)r �prompt_managerr<)r rrrrrr�contexts r �create_structured_promptrE�s?��0����� �2��#�)�r�+��G� � '� '�� 0�0r)NNNNN)r�jinja2r�typingrrr�pydanticrr�jsonr r"rCrrrErrr �<module>rJs���� �&�&�%� �_�)�_�D+�D+�P'�(�� #�#'�#�)-�'+�"1��"1� �"1��s�m�"1��d�3�i� � "1� ��}� "1� �D��I�&� "1� ��}�"1� �"1r

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zbrdc/delia'

If you have feedback or need assistance with the MCP directory API, please join our Discord server