The development of functional Python code often presents significant challenges, demanding a deep understanding of the language and exceptional debugging abilities. Developers frequently encounter difficulties in crafting efficient code or resolving complex errors, leading to time-consuming and frustrating experiences. To address these hurdles, we have developed an innovative AI system capable of generating Python code based on user-provided prompts. Furthermore, this system excels at identifying and rectifying errors within existing Python code, offering clear explanations and potential solutions. By automating these tasks, our AI system significantly streamlines the development process, enabling developers to focus on higher-level problem-solving and enhancing overall productivity.
- LangChain
- Hugging Face
- Streamlit
In the “Python Code Fixer and Error Explainer System” I have used CodeLlama and Zephyr models. CodeLlama is utilized to fix the errored code of the user. With prompt engineering, I crafted a custom prompt that incorporates instructions about what the CodeLlama should do. The prompt also includes the user’s error code and the error message generated by the Python interpreter. This prompt acts as input to the CodeLlama model. Considering the error message with respect to the user's code, the CodeLlama model fixes the error and produces the error-free fixed code. The Zephyr model also takes a custom prompt mentioning “explain the error.” After understanding the error, the model outputs a short but accurate explanation of the error message to make the user understand what causes the error.
In the “Python Code Writer System” I have used the CodeLlama mode. A custom prompt has been crafted and tested mentioning that the model is an expert Python programmer and its job is to write error-free Python code as per the user's question. This prompt plus user’s question is given to the model to generate an accurate and optimized Python code.
Code Llama is a code-specialized version of Llama 2 that was created by further training Llama 2 on its code-specific datasets, sampling more data from that same dataset for longer. Essentially, Code Llama features enhanced coding capabilities, built on top of Llama 2. It can generate code, and natural language about code, from both code and natural language prompts. It can also be used for code completion and debugging.
Zephyr is a series of language models that are trained to act as helpful assistants. Zephyr-7B-β is the second model in the series, and is a fine-tuned version of mistralai/Mistral-7B-v0.1 that was trained on on a mix of publicly available, synthetic datasets using Direct Preference Optimization (DPO).
code_fixer.mp4
code_generator.mp4
Commenting.the.code.mp4
Here in this project, I have built an AI system that writes Python code as per user's question, fixes the errors of the user's code, explain the error and also comment out the code using two large language modes, i.e. CodeLlama and Zephyr.