16 releases (10 breaking)

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

#576 in Web programming

Download history 126/week @ 2024-08-23 20/week @ 2024-08-30 46/week @ 2024-09-13 168/week @ 2024-09-20 42/week @ 2024-09-27 221/week @ 2024-10-04 371/week @ 2024-10-11 155/week @ 2024-10-18 3/week @ 2024-10-25 134/week @ 2024-11-22 11/week @ 2024-11-29

145 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
~265K SLoC