Giter VIP home page Giter VIP logo

gems's Introduction

๐Ÿ’Ž Gems

Crates.io docs License

๐Ÿ’Ž GEMS: A cli, tui, and sdk for interacting with the Gemini API, allowing you to generate creative content, perform text-related tasks, and get information about supported models.

๐Ÿ“– Table of Contents

๐Ÿš€ Installation

To install the gems cli, use the following Cargo command:

cargo install --locked gems --all-features

โœจ Features

  • Interact with the Gemini API from the terminal.
  • Generate creative content with ease.
  • Stream generation of content for continuous output.
  • Count the number of tokens in a text.
  • Embed content into a specified model.
  • Batch embed multiple contents efficiently.
  • Get information about the current model and list available models.

Usage

Before using the gems CLI, make sure to set the following environment variables:

export GEMINI_API_KEY=<your_gemini_api_key>
export GEMINI_MODEL=<your_gemini_model>

Generate an api key from Google AI Studio.

โŒจ Usage as CLI

Generate creative content:

gems generate -t "Hello"

Analyze an image and generate content from text:

curl -o image.jpg https://storage.googleapis.com/generativeai-downloads/images/scones.jpg

gems vision -i image.jpg

gems vision -i image.jpg -t "What's in the image?"

Stream generation of content:

gems stream -t "Generate a short fictional story"

Count the number of tokens in a text:

gems count -t "Hello There!"

Embed content into a specified model:

gems -m 'embedding-001' embed -t "Write a story about a magic backpack."

Batch embed multiple contents:

gems -m 'embedding-001' batch -t "Write a story about a magic backpack.","Generate a poem about nature."

Get information about the current model:

gems info

List available models:

gems list

๐ŸŽจ Options

Option Description
--api-key Specify the API key for accessing the Gemini API.
--model Specify the model to use for generating content.

๐Ÿ›  Subcommands

Subcommand Description
generate Generate creative content.
vision Analyze an image and generate content from text.
stream Stream the generation of content.
count Count the number of tokens in a text.
embed Embed content into a specified model.
batch Batch embed multiple contents.
info Get information about the current model.
list List available models.

โœจ Usage as Dependency

  1. Add the gems crate:

    [dependencies]
    gems = "0.0.7"
  2. Use the Client struct to interact with the Gemini API:

    use gems::Client;
    
    #[tokio::main]
    async fn main() {
        let mut client = Client::new("your_api_key", "your_model");
    
        // Use the various functions provided by the client
        // For example:
        match client.generate_content("Hello").await {
            Ok(response) => {
                println!("{}", response);
            }
            Err(err) => {
                eprintln!("Error: {:?}", err);
            }
        }
    }

๐Ÿ“Œ Examples

This repository contains a list of notebooks examples on how to use the sdk and or the cli. To use the notebooks in this repository, you need to set up your environment. Follow these steps to get started:

  1. Clone the repository to your local machine:

    git clone https://github.com/wiseaidev/gems.git
  2. Install the required dependencies and libraries. Make sure you have Rust, Jupyter Notebook, and evcxr_jupyter installed on your system.

    # Install a Rust toolchain (e.g. nightly):
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly
    
    # Install Jupyter Notebook
    pip install notebook
    
    # Install evcxr_jupyter
    cargo install evcxr_jupyter
    evcxr_jupyter --install 
  3. Navigate to the cloned repository and build the project:

    cd gems
    cargo build --release --all-features
  4. Start Jupyter Notebook:

    jupyter notebook
  5. Access the notebooks in your web browser by clicking on the notebook file you want to explore.

ID Example Open on GitHub Launch on Binder Launch on Colab
1 Basic Github Binder Open In Colab
2 Rocket Github Binder Open In Colab
3 Axum Github Binder Open In Colab

๐Ÿค Contributing

Contributions and feedback are welcome! If you'd like to contribute, report an issue, or suggest an enhancement, please engage with the project on GitHub. Your contributions help improve this crate for the community.

๐Ÿ“„ License

This project is licensed under the MIT License.

gems's People

Contributors

wiseaidev avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

zojeda

gems's Issues

TODO

  • Multi-turn conversations.
  • Chat sessions.
  • tui using ratatui
  • Web app using Next RS?
  • Gemini vision.
  • Examples with backend frameworks (e.g. axum, rocket, etc)

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.