Kody is a Python application designed to assist in code generation tasks by leveraging AI models and parsing tools. It can help in assisting to understand your code and can also generate test scripts.As we use Ollama this runs entire in your machine.Downside is you have to download the model on your machine,more localization is directly proportional to memory.You can download ollama from the official repo here. Warning:Its not completely local per se as I used LlamaCloud API to parse the documents for better results.
I wanted to try this for a pretty long time now.Using your own custom data to query the model without having to get into the network and using techniques such as transfer learning and fine tuning it to our datasets.It took me quite alot of time to get this to work.To prevent timeout I had to set the timeout to 10000 seconds.
I used one of my other project's source code which you can also find here.
- llama_index: A framework for loading, indexing, and querying documents, integrating with language models.
- Ollama (Mistral Model): An open-source LLM used for code generation tasks.
- LlamaParse: A tool for parsing documents, particularly PDF files, to extract relevant information.
- ReActAgent: A custom agent class responsible for coordinating interactions with LLMs and managing queries.
- Codellama Model: An LLM tailored for code-related tasks, used within the ReActAgent.
- FunctionTool (llama_index): A utility for wrapping Python functions as tools usable by LLMs.
- Pydantic: A data validation library for defining structured output formats.
Prompt: Read the content of main.py and write a python script that submits a post request i.e using symptoms given in the file.
The code is stored in the output directory which was also named main.py
- Data Loading: Documents are loaded and indexed for efficient querying.
- Code Generation: User prompts are provided to the ReActAgent, which utilizes Ollama (Codellama model) to generate code snippets.
- Output Processing: The generated code responses are parsed and validated using Pydantic.
- File Saving: Validated code snippets are saved to files for further use.
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables in a
.env
file. - Use your custom data (make sure the varibles such as folder name match with yours)
- Run
main.py
and input your prompt to generate and save code snippets.Be specific in your prompts,use your file name.