Crate gruq

Source
Expand description

§Groq Unofficial Rust SDK

Crates.io MIT licensed APACHE-2.0 licensed Build Status

This is an unofficial Rust SDK for the Groq API.

More information about this crate can be found in the crate documentation.

§Installation

Add gruq as a dependency to your Cargo.toml

$ cargo add gruq

§Usage

An example to create a completion.

use gruq::{
    chat::message::{CreateChatCompletion, Message, Role},
    client::Client,
    config::Config,
    models::Model,
};

#[tokio::main]
async fn main() {
    let config = Config::from_env().unwrap();
    let client = Client::new(config).unwrap();

    let messages: Vec<Message> = vec![Message {
        role: Role::User,
        content: "Hello World".to_string(),
        name: None,
    }];
    let completion_request = CreateChatCompletion::new(Model::Llama38B, messages);
    let completion = client
        .chat
        .create_completion(completion_request)
        .await
        .unwrap();
    println!("{:?}", completion);
}

§License

This project is licensed under the MIT license and Apache-2.0 license.

Modules§

chat
client
config
error
models