Crate replicate_rs

source ·
Expand description

A simple http client for interacting with Replicate.
Provides simple async functionality for interacting with Replicate via serde and isahc.

Getting Started

Add the following to your cargo toml

replicate-rs = "0.2.0"

Examples

Create a Prediction

Create a prediction, and get refreshed prediction data.

use replicate_rs::config::ReplicateConfig;
use replicate_rs::predictions::PredictionClient;
use serde::Serialize;

let config = ReplicateConfig::new().unwrap();
let prediction_client = PredictionClient::from(config);

#[derive(Serialize)]
struct HelloWorldInput {
    text: String
}

// The library is async agnostic, so you should be able to use any async runtime you please
tokio_test::block_on(async move {

    // Create the prediction
    let prediction_input = Box::new(HelloWorldInput{ text: "kyle".to_string() });
    let mut prediction = prediction_client
        .create(
            "replicate",
            "hello-world",
            prediction_input
        )
        .await
        .unwrap();

    // Refresh the data
    prediction.reload().await;
})

Modules

  • Utilities for high level configuration for Replicate clients.
  • Utilities for interacting with models endpoints.
  • Utilities for interacting with all prediction endpoints.