LLMCheatsheets.jl is a Julia package that makes it easy and instant to teach AI models about new packages and repositories by creating cheatsheets from GitHub repositories. This tool bridges the gap between human-readable documentation and AI-friendly knowledge representation, allowing for seamless integration with language models and AI assistants.
By default, we take a subset of the folders and files in the provided repository and summarize them using an LLM into a single cheatsheet.
To install LLMCheatsheets.jl, use the Julia package manager and the repo URL (it's not registered yet):
using Pkg
Pkg.add(url = "https://github.com/svilupp/LLMCheatsheets.jl")
Tip
If you encounter rate limits when accessing the GitHub API, you can set up a personal access token and set it as an environment variable GITHUB_API_KEY
to increase your request limit to 5000 per hour.
Here's a basic example of how to use LLMCheatsheets.jl to create a cheatsheet for a GitHub repository.
using LLMCheatsheets
repo = GitHubRepo("https://github.com/svilupp/PromptingTools.jl")
create_cheatsheet(repo; save_path = true);
With save_path = true
, the cheatsheet will be saved to folder llm-cheatsheets
in the current working directory.
What happens behind the scenes:
repo.paths
and repo.file_types
.For a low-level interface to generate the files individually and process them yourself, see examples/create_for_promptingtools.jl
.
Sometimes you might want to just download the files without summarizing them. You can do that with collect
function.
files_str = collect(repo)
files_str
will be a string with all scanned files concatenated together.
To use it in ChatGPT or Claude.ai, use clipboard
functionality to copy it to clipboard - files_str|>clipboard
.
By default, the files scanned and downloaded are repo.paths
and repo.file_types
, respectively.
By default, repo.paths
includes ["src", "docs/src", "README.md"]
, and repo.file_types
includes [".jl", ".md"]
. You can customize these when creating the GitHubRepo
object:
Eg, adding a folder examples
and .txt
files to customize what we will summarize:
repo = GitHubRepo("https://github.com/username/repository"; paths = ["examples", "README.md"], file_types = [".jl", ".md", ".txt"])
You can use a different LLM by passing the model
argument to the functions.
create_cheatsheet(repo; save_path = true, model = "gpt4om")
You can provide special instructions to guide the AI in generating the cheatsheet:
create_cheatsheet(repo; special_instructions = "Focus on the data structures and their interactions.")
You can simply export also ai* functions from PromptingTools.jl to use them with LLMCheatsheets.jl.
using LLMCheatsheets
# Re-export aigenerate, pprint from PromptingTools
using LLMCheatsheets: aigenerate, pprint
# Or import PromptingTools directly
# using PromptingTools
repo = GitHubRepo("https://github.com/svilupp/PromptingTools.jl"; paths = ["docs/src", "README.md"])
files_str = collect(repo)
msg = aigenerate("Read through these files: $(files_str)nnAnswer the question: What is the function for creating prompt templates?")
pprint(msg)
The function for creating prompt templates in the `PromptingTools.jl` package is `create_template`. This function allows you to define a prompt with placeholders and save it for later use. The syntax is:
```julia
create_template(; user=<user prompt>,
system=<system prompt>, load_as=<template name>)
```
This function generates a vector of messages, which you can use directly in the `ai*` functions. If you provide the `load_as` argument, it will also register the template in the template store,
allowing you to access it later using its name.
If you are getting rate-limited by LLM providers, you can decrease the number of concurrent summarization tasks in create_cheatsheet
by setting a lower number like ntasks=5
or ntasks=2
(depends on your API tier).
Set up a personal access token and set it as ENV["GITHUB_API_KEY"]
.
It will be automatically loaded into a variable LLMCheatsheets.GITHUB_API_KEY
.
You can set up a personal access token for GitHub API by following these steps:
Then you can set it as ENV["GITHUB_API_KEY"]
or LLMCheatsheets.GITHUB_API_KEY
.
For more information about using LLMCheatsheets.jl, please refer to the documentation.
If you encounter any issues or have questions, please open an issue on the GitHub repository.