Giter VIP home page Giter VIP logo

chatdir's Introduction

chatdir

A CLI tool to prompt Google Gemini with the contents of a directory.

Gemini 1.5 Pro has a 2 million token context window, while Gemini 1.5 Flash has a 1 million token context window. Additionally, both models have a free tier. This makes Gemini 1.5 great for high-level prompts over entire directories of your codebase.

Chatdir lets you easily prompt Gemini with an entire directory.

Setup

jq is required as a dependency:

brew install jq

Usage

API Key

Create an API Key to use the Gemini API.

Then, make sure to include it as an environment variable:

GEMINI_API_KEY="your-api-key" ../path/to/chatdir.sh "What is in this directory?"

Or, use the --env flag to load the key from a .env file:

../path/to/chatdir.sh --env ../path/to/.env "What is in this directory?"

Aliasing

Alternatively, you can create an alias in your .zshrc:

# chatdir
chatdir() {
  ~/path/to/chatdir/chatdir.sh --env ~/path/to/chatdir/.env "$@"
}

Then, simply source your .zshrc or restart your terminal to apply the changes:

source ~/.zshrc

You should now be able to use the chatdir command from anywhere in your terminal.

Options

By default, gitignored files are excluded from the prompt.

You can preview the files that will be included by using the --ls flag. Additionally, you can preview the full prompt by using the --stdout flag, or the curl command that will be sent to Google with the --dry-run flag.

Usage: chatdir [question] [directory]
   -e, --env <file>   Load GEMINI_API_KEY from a .env file
   -m, --model <name> Use the specified model (default: gemini-1.5-pro-latest)
       --flash        Use the gemini-1.5-flash-latest model
       --ls           List all targeted files
       --stdout       Print the generated prompt to stdout
       --tokens       Count the tokens in the generated prompt without prompting the model
       --dry-run      Print the resulting curl command without executing it
   -h, --help         Show this help message

Prompt Format

Prompts use the following format:

Project Directory: /path/to/dir

Included Files:

```
/path/to/dir/file1.ext
/path/to/dir/file2.ext
```

`/path/to/dir/file1.ext`:

```````ext
file1...
```````

`/path/to/dir/file2.ext`:

```````ext
file2...
```````

---

Your question here

chatdir's People

Contributors

bconnorwhite avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.