16 releases (10 breaking)

new 0.14.0 Nov 23, 2024
0.12.1 Oct 11, 2024
0.8.1 Jul 18, 2024

#501 in Web programming

Download history 28/week @ 2024-07-27 131/week @ 2024-08-24 15/week @ 2024-08-31 51/week @ 2024-09-14 175/week @ 2024-09-21 114/week @ 2024-09-28 252/week @ 2024-10-05 358/week @ 2024-10-12 54/week @ 2024-10-19 2/week @ 2024-10-26

158 downloads per month

Apache-2.0

125KB
2K SLoC

Prediction Guard Rust Client

CircleCI crates.io

Description

This crate provides functionality developed to simplify interfacing with Prediction Guard API in Rust.

Requirements

To access the API, contact us here to get an enterprise access token. You will need this access token to continue.

Usage

extern crate prediction_guard as pg_client;

use pg_client::{chat, client, models};

#[tokio::main]
async fn main() {
    let clt = client::Client::new().expect("client value");

    let req = chat::Request::<chat::Message>::new("NeuralChat7B".to_string())
        .add_message(
            chat::Roles::User,
            "How do you feel about the world in general?".to_string(),
        )
        .max_tokens(1000)
        .temperature(0.85);

    let result = clt
        .generate_chat_completion(&req)
        .await
        .expect("error from generate chat completion");

    println!("\nchat completion response:\n\n {:?}", result);
}

Take a look at the examples directory for more examples.

Docs

You can find the Prediction Guard API docs on the Prediction Guard website.

API Docs

API Reference

Getting started

Once you have your api key you can use the makefile to run curl commands for the different api endpoints. For example, make curl-injection will connect to the injection endpoint and return the injection response. The makefile also allows you to run the different examples such as make run-injection to run the injection example.

Licensing

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2024 Prediction Guard

Dependencies

~9–20MB
~264K SLoC