ROLE="You are an experienced python software developer responsible for code review and feedback." TASK="Review the following python code by considering the best practices given in the guidelines below and provide your Observations and Suggestions." INSTRUCTIONS="""Identify the code. If no code is present then say 'No code given'. Take a deep breath before providing the feedback and thoroughly understand the code logic. Avoid verbosity and repetition in your feedback, focussing on essential points and offering valuable suggestions. Add your own observations and suggestions as needed, and only include comments that are neccessary for clarity and improvement. If you have specific code suggestions, ensure they are correct and aligned with the best practices. """ GUIDELINES = f""" Use Intention-Revealing Names. Pick one word per concept Use Solution/Problem Domain Names Classes should be small Functions should be small Do one Thing Declare constants as applicable Don't Repeat Yourself (Avoid Duplication) Explain yourself in code Make sure the code formatting is applied Use Exceptions rather than Return codes Don't return Null Favor the use of standard exceptions Don't ignore exceptions Check parameters for validity Return empty arrays or collections, not nulls Minimize the accessibility of classes and members In public classes, use accessor methods, not public fields Minimize the scope of local variables Refer to objects by their interfaces Adhere to generally accepted naming conventions Avoid finalizers Synchronize access to shared mutable data Valid unit test cases exist Objects accessed by multiple threads are accessed only through a lock, or synchronized methods. Race conditions have been handled Locks are acquired and released in the right order to prevent deadlocks, even in error handling code. All methods are commented in clear language """ #First check whether the given input contains any code snippet or not. STEPS="""Follow the steps in the same order: 1. Understand the code logic and structure. 2. Notedown the observations based on the guidelines given above. 3. Give suggestions for improving the code. 4. Give an example of Final improved code. """ def default_review_prompt1(code, guidelines=None): if guidelines is None: guidelines=GUIDELINES prompt=f"""<Task>: {ROLE} {TASK} <Instructions>: {INSTRUCTIONS} <Guidelines>: {guidelines} <Steps to follow>: {STEPS} <code>: {code} """ return prompt def default_review_prompt2(code): prompt=f"""<Task>: {ROLE} {TASK} <Intsructions>: Analyze the provided code and identify the key components (classes, functions, modules). 1. Analyze each key component following chain of thoughts. Consider the purpose of the component, its readability, efficiency, and adherence to the listed custom guidelines. 2. Break down your review into a step-by-step process, explaining your reasoning at each point. Maintain a clear and concise tone throughout the review. 3. Add your own observations and suggestions as needed, and only include comments that are neccessary for clarity and improvement. 4. Highlight serious violations. 5. Give suggestions for improving the code. 6. Give an example of Final improved code. <Guidelines>: {GUIDELINES} <Steps to follow>: {STEPS} <code>: {code} """ promptt=f""" <task>: {ROLE} Review the following code by considering the best practices given in the guidelines below. <Guidelines>: {GUIDELINES} <Code>: {code} """ return prompt def default_review_prompt3(code): prompt= f"""Conduct a comprehensive code review of the provided Python script, focusing on its structure, functionality, and adherence to best practices.\ The script is designed to automate a specific task, and your review should assess its efficiency, readability, and maintainability. <Guidelines for the Code Review>: - Understand the script: Check whether the script contains a python script or not. - Structure and Organization: Evaluate the script's overall structure and organization. Is the code logically divided into functions or sections? Are there any redundant or unnecessary sections? - Declare constants as applicable: Make sure constants are declared whenever applicable. - Functionality and Correctness: Assess the script's functionality and correctness. Does it perform the intended task correctly? Are there any potential errors or edge cases that could cause issues? - Readability and Code Quality: Evaluate the script's readability and code quality. Are the variable names descriptive and consistent? Are there any unnecessary comments or redundant code? - Efficiency and Performance: Analyze the script's efficiency and performance. Are there any opportunities to optimize the code for better performance or reduce computational complexity? - Best Practices and Conventions: Check the script's adherence to best practices and coding conventions. Are there any deviations from standard Python coding conventions or best practices? - Error Handling and Debugging: Evaluate the script's error handling and debugging capabilities. Are there any try-except blocks or logging statements to handle potential errors? - Code Duplication and Redundancy: Identify any duplicated or redundant code sections. Are there any opportunities to refactor the code to reduce duplication? - Security and Vulnerabilities: Assess the script's security and potential vulnerabilities. Are there any sensitive data or user input handling that could lead to security issues? - Documentation and Comments: Evaluate the script's documentation and comments. Are there any clear and concise comments explaining the code's purpose and functionality? - Testing and Validation: Suggest any additional testing or validation steps to ensure the script's correctness and reliability. <Deliverables>: A detailed report summarizing the code review findings, including any suggestions for improvement. A revised version of the script incorporating the recommended changes and improvements. <Script>: {code} """ return prompt def custom_review_prompt(c_prompt,code): return f'{c_prompt}\n<Code>: {code}' def default_refine_prompt(code): prompt= f"""You are an expert software engineer and your task is to refine and optimize the code provided below while ensuring accuracy and functionality are maintained. Please follow the guidelines on best practices outlined to refine the code's efficiency and readability. <Guidelines on Best Practices>: - Use Intention-Revealing Names - Declare constants as applicable - Don't Repeat Yourself (Avoid Duplication) - Explain yourself in code - Make sure the code formatting is applied - Use Exceptions rather than Return codes - Don't return Null - Favor the use of standard exceptions - Don't ignore exceptions - Check parameters for validity - Return empty arrays or collections, not nulls - Minimize the accessibility of classes and members - In public classes, use accessor methods, not public fields - Minimize the scope of local variables - Refer to objects by their interfaces - Adhere to generally accepted naming conventions - Avoid finalizers - Synchronize access to shared mutable data - Valid unit test cases exist - Objects accessed by multiple threads are accessed only through a lock, or synchronized methods. - Race conditions have been handled - Locks are acquired and released in the right order to prevent deadlocks, even in error handling code. - All methods are commented in clear language - Use List Comprehension: Consider using list comprehension wherever possible. - Error Handling: Implement error handling to handle cases where the input is invalid. - Function Modularity: If possible, break down the code into smaller, more modular functions for better code organization. - Docstrings: Include clear and concise docstrings to describe the purpose of functions and any parameters they accept. - Variable Naming: Use descriptive variable names to improve code readability. - Efficient Algorithms: Opt for efficient algorithms and data structures to improve performance where possible. - Testing: Conduct thorough testing to ensure the optimized code produces the same results as the original. Your expertise in refining and optimizing this code will greatly enhance its efficiency and maintain its functionality. <Deliverables>: A refined and optimized version of the code. <Code>: {code} """ return prompt def default_doc_prompt(code): prompt= f""""**Role:** Technical Writer **Task:** Generate formal documentation for the provided Python code. **Context:** The provided Python code snippet requires comprehensive formal documentation. This documentation should clearly explain the code's functionality and purpose, including all relevant details expected in formal documentation. **Instructions:** * Take a deep breath and thoroughly analyze the provided Python code. * Understand the code's logic, flow, and intended functionality. * Generate formal documentation that is clear, concise, and informative. * Explain the code's purpose, functionality, and any relevant details. * Use proper formatting, structure, and language appropriate for formal documentation. * Ensure the documentation is comprehensive and addresses all aspects of the code. **Guidelines:** * Follow the guidelines for writing formal documentation. * Use clear and concise language. * Avoid ambiguity and ensure the documentation is easy to understand. * Use proper grammar and punctuation. * Structure the documentation logically and use headings and subheadings for clarity. * Include relevant comments and explanations within the code itself. **Examples:** * Provide examples of how the code can be used. * Include code snippets to illustrate specific functionalities. * Use diagrams or flowcharts to visualize complex logic. **Steps:** 1. Analyze the Python code and understand its functionality. 2. Gather all relevant information about the code, including its purpose, inputs, outputs, and any dependencies. 3. Structure the documentation logically, using headings and subheadings to organize the information. 4. Write clear and concise explanations of the code's functionality. 5. Include relevant examples and code snippets to illustrate the code's usage. 6. Proofread and edit the documentation carefully to ensure accuracy and clarity. **Goal:** Generate comprehensive and accurate formal documentation for the provided Python code in one iteration. **Additional Notes:** * Consider using a documentation generator tool to assist with the formatting and structure of the documentation. * Review the documentation with a technical expert to ensure its accuracy and completeness. * If further clarification is needed, feel free to ask for additional information or context regarding the code. **Code:** {code} """ promptt = f"""**Instruction**: As an adept programmer, meticulously dissect the given code snippet and meticulously document it in accordance with the provided Output Format. If you encounter any functionalities or concepts you're uncertain about, provide the best possible descriptions and indicate areas necessitating further investigation. Avoid conjectures and ensure explanations are substantiated. If certain sections of the **Output Format** aren't applicable, simply exclude them from the output. **Output Format**: ##Dependencies: 1. Frameworks/Libraries: List any external libraries, frameworks, or modules required by the code along with a succinct description for each. 2. Cloud Services: Enumerate all cloud services invoked within the code, providing a concise description for each service's purpose or functionality in one line. ## Functions used: Present a clear and organized table showcasing the name of each function, along with its corresponding input/arguments, expected output, and the function's purpose. The table should be formatted neatly for easy readability. All "|" should fall on same line. Use the following column headings: | Function Name | Input/Arguments | Output | Purpose | ##Steps Conducted: Translate the developer's actions for each function into a detailed and easily readable format. Additionally, include a flow diagram to illustrate the code's flow step by step. ##Suggestions for Improvement: Offer recommendations for enhancing the code, potential optimizations, or logic enhancements. Provide a code snippet for each suggestion, avoiding unnecessary assumptions. Task: Showcase your proficiency by creating a comprehensive documentation set for the provided code snippet. Adhere strictly to the outlined Output Format. **Code**: {code} """ return prompt def resume_prompt(details, guidelines=None): prompt=f"""**Role:** Resume Writer **Task:** Generate a well-structured, impactful resume brief based on the provided candidate's resume. **Context:** You are a professional resume writer with extensive experience in crafting compelling resumes that effectively showcase candidates' skills and experience. You have access to the candidate's resume and are familiar with industry best practices for resume writing. **Instructions:** * Take a deep breath and thoroughly analyze the candidate's resume. * Identify the most relevant and impactful information that aligns with the target job description. * Use a formal and impactful tone while highlighting the candidate's key strengths and accomplishments. * Structure the resume brief in a clear and concise manner, using bullet points and headings for easy readability. * Ensure that the resume brief is tailored to the specific job the candidate is applying for. **Guidelines:** * Follow industry best practices for resume writing. * Use clear and concise language. * Avoid jargon and technical terms that the hiring manager may not understand. * Proofread carefully for any errors in grammar or spelling. **Example:** **Candidate:** John Doe **Target Job:** Software Engineer **Resume Brief:** * **Summary:** Highly motivated and results-oriented software engineer with 5+ years of experience in developing and maintaining complex software applications. Proven ability to work independently and as part of a team. * **Technical Skills:** Proficient in Java, Python, C++, and SQL. Experience with Agile methodologies and cloud computing platforms. * **Experience:** * Developed a new customer relationship management system that resulted in a 20% increase in sales. * Led a team of engineers in the development of a new mobile app that has been downloaded over 1 million times. * **Education:** Bachelor of Science in Computer Science from the University of California, Berkeley. **Steps:** 1. Review the candidate's resume and identify their key skills and experience. 2. Determine the target job description and identify the most relevant information from the resume. 3. Write a concise and impactful summary of the candidate's qualifications. 4. Highlight the candidate's technical skills and experience. 5. Provide specific examples of the candidate's accomplishments. 6. Proofread the resume brief carefully. **Goal:** To generate a well-structured, impactful resume brief that effectively showcases the candidate's qualifications and increases their chances of landing an interview. **Additional Notes:** * Consider including a call to action at the end of the resume brief, such as "Please contact me to discuss my qualifications in more detail." * You may also want to include a link to the candidate's full resume. * If you have any questions about the candidate's qualifications, be sure to reach out to them for clarification. **By following these guidelines and steps, you can generate an effective prompt that will help the model generate a well-structured, impactful resume brief in one go.** Details: {details} """ return prompt def validation_prompt(code, guidelines=None): prompt=f"""Check if the below input contains code snippets or not. Return only Yes or NO and nothing else. Input: {code} """ return prompt