This repository contains a Bash script that interacts with GitHub's Models API. The script provides various functionalities such as listing available models, showing rate limits, and making API calls to generate responses based on user prompts.
To use this script, you need to have jq, file, and pdftotext installed. You can install them using the following commands:
sudo apt-get install jq file poppler-utilsClone this repository to your local machine:
git clone https://github.com/KimSchm/github-models-bash.git
cd github-models-bashMake the script executable:
chmod +x github_llm.shHere are some examples of how to use the script:
-
List all available models:
./github_llm.sh -l <token>
-
Generate a response based on a user prompt:
./github_llm.sh "Explain recursion" openai/gpt-4o <token>
-
Include a file as context:
./github_llm.sh -f src/app.js "Refactor this" openai/gpt-4o <token>
-
Include all files under a directory as context:
./github_llm.sh -d src "Summarize module" openai/gpt-4o <token>
-
Include all files under a directory and its subdirectories as context:
./github_llm.sh -r src "Summarize module recursively" openai/gpt-4o <token>
-
Show rate limits for a model:
./github_llm.sh --rate openai/gpt-4o <token>
The script supports the following file types:
- Text files (e.g.,
.txt,.md) - PDF files (requires
pdftotext) - Image files (e.g.,
.jpg,.png) - Audio files (e.g.,
.mp3,.wav)
For unsupported file types, the script will use the text option.
To use this script, you need a GitHub Personal Access Token (PAT) with models:read permission. Follow these steps to generate one:
- Go to GitHub Settings - Tokens.
- Click "Generate new token" (choose "Fine-grained token" if available).
- Give your token a descriptive name and (optionally) set an expiration.
- Under "Resource owner," select your user or organization.
- Under "Repository access," select "All repositories" or limit as needed.
- Under "Permissions," add:
models:read
- Click "Generate token" and copy the value (it will only be shown once).
- Use this token as the last argument to this script.
For more details, see GitHub Documentation.
TIP: Never share your token publicly. Treat it like a password.
We welcome contributions to this project. Please follow these guidelines when contributing:
- Fork the repository and create your branch from
main. - If you've added code that should be tested, add tests.
- Ensure the test suite passes.
- Make sure your code lints.
- Issue that pull request!
This project adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code.
If you encounter any issues or have feature requests, please use the GitHub Issues page to report them.
This project is maintained by KimSchm.