Coder Social home page Coder Social logo

geminicli's Introduction

GeminiCLI

GeminiCLI is a command-line interface tool written in Go, designed to interact with the generative language API provided by Google. It enables users to generate content by sending requests to the API and receiving responses directly in the terminal. This tool is particularly useful for developers and researchers working on natural language processing and generative AI models.

Features

  • Send requests to the generative language API.
  • Save conversation history in markdown files with timestamps.
  • Clear screen functionality for better user experience.
  • Load context from a file to influence the generation.
  • Command-line flags for flexible configuration.

Pre-Requisites

  1. Before installing GeminiCLI, ensure you have Go installed on your system. You can download and install Go from the official Go website.
  2. Setup an API Key for Gemini by following this documentation - Gemini API Key

Installation

To install GeminiCLI, clone the repository to your local machine:

git clone https://github.com/benjaminwestern/geminicli.git cd geminicli

Change directory to the geminicli repo you just cloned, then, build the binary using:

go build .

This will create the geminicli executable in your current directory.

Usage

To start using GeminiCLI, you can run the executable directly from the command line.

Here are some common commands to get you started:

  • To generate content with a context file:
./geminicli -context path/to/your/context.txt
  • To specify an output file for the conversation log:
./geminicli -output path/to/your/output/
  • For help and a list of available flags:
./geminicli -help

Environment Variables

GeminiCLI expects the API_KEY environment variable to be set with your API key.

You can set this variable in your shell configuration file, or export it directly in the terminal:

export API_KEY=your_api_key_here

Model Configuration

You can also set some other environment variables to configure the tool's behaviour. The following environment variables are available for configuration:

  • TOP_K - The top-k value for the generation. Default: 1
  • TOP_P - The top-p value for the generation. Default: 1
  • TEMPERATURE - The temperature value for the generation. Default: 0.9
  • MAX_TOKENS - The maximum number of tokens to generate. Default: 2048
  • MODEL_TYPE - The model to use for the generation. Default: gemini-1.0-pro
  • API_VERSION - The version of the generative language API to use. Default: v1beta

Safety Settings

The generative language API has a number of safety settings that can be configured to control the content generated by the model. These settings are available as environment variables:

  • HARASSMENT - The harassment setting for the generation. Default: BLOCK_NONE
  • HATE_SPEECH - The hate speech setting for the generation. Default: BLOCK_NONE
  • SEXUALLY_EXPLICIT - The sexually explicit setting for the generation. Default: BLOCK_NONE
  • DANGEROUS_CONTENT - The dangerous content setting for the generation. Default: BLOCK_NONE

The available options for these settings are: Reference can be found here

  • HARM_BLOCK_THRESHOLD_UNSPECIFIED - Threshold is unspecified.
  • BLOCK_LOW_AND_ABOVE - Content with NEGLIGIBLE will be allowed.
  • BLOCK_MEDIUM_AND_ABOVE - Content with NEGLIGIBLE and LOW will be allowed.
  • BLOCK_ONLY_HIGH - Content with NEGLIGIBLE, LOW, and MEDIUM will be allowed.
  • BLOCK_NONE - All content will be allowed.

Ensure you have at least the API_KEY set as an environment variable with your API key before running the tool.

Contributing

I welcome contributions from the community! If you'd like to contribute to GeminiCLI, please fork the repository and submit a pull request with your changes. For major changes, please open an issue first to discuss what you would like to change.

License

GeminiCLI is open-sourced under the MIT License. See the LICENSE file for more details.

Getting Help

If you encounter any issues or have questions about using GeminiCLI, please open an issue on the GitHub issue tracker. For more information about the generative language API and its configuration, visit Google's API documentation.

Important Information

Please ensure you are aware that anything you input into these models (if your using a personal google account) will be utilised to further train the Gemini models, so PLEASE think twice before sending private content to these models! Google's Gemini FAQs

TODO QOL

  • Add tests.
  • Add CI/CD to build and test the tool on each commit.
  • Update the handling of environment variables to be more flexible.

TODO Features

  • Add support for changing output file format (e.g. JSON, plaintext).
  • Add support to disable the output file.
  • Add support for changing the output file name.
  • Add support for reading context from files in a folder.
  • Add support for handling API Responses other than 200 OK.
  • Add support for defining Environment file location for configuration.
  • Add support for the setting of Environment variables in the tool.

geminicli's People

Contributors

benjaminwestern 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.