How to export the contents of your code repository for use with LLMs
Posted on April 11, 2024 - by Andy Cinquin
Code exportLLMIntegration with LLMNPM packageRepo to LLM
How to export the contents of your code repository for use with LLMs
Introduction:
Do you have a repository that you want to export to an LLM so you can get full answers and fewer hallucinations from your favorite LLM? In this article, we'll look at how to correctly use the library I've created to solve this problem.
Step 1: Installation
The easiest way is to install the npm package globally with :
npm install -g export-repository-to-file
You can then use the
export-repo
command in your terminal.Step 2: Configure exclusions (optional)
By default, the library uses the
.gitignore
file at the root of your repository to determine which files and folders to ignore. You can also create an .exclusionListConfig
file to list export-specific exclusions, such as configuration files, dependencies and so on.(Often, we'll need to look in the
large_files_output.txt
file to see which large files we could add to the exclusion list).Step 3: Launch export
In your terminal, navigate to your repository folder and run the command :
export-repo ./ -o myExport.txt -l largeFile.txt
This will generate the file
myExport.txt
with the textual content of your code, excluding what is listed in .gitignore
and .exclusionListConfig
.Useful options :
-p
to specify a preamble file to include at the beginning-l
to list files exceeding 250 lines or 2500 characters in a separate file-e
to give a file listing additional exclusions
Step 4: Using the generated file
You can now copy and paste the contents of
myExport.txt
when talking to ChatGPT or another LLM to give it the context of your code base.And that's it! Now all you have to do is use it in your favorite LLM!
Thank you for your visit, feel free to contact me for
any information, quote or collaboration proposal. I will
be happy to answer you as soon as possible.
Did you like this article? Feel free to share it!