pub struct Prediction {
pub parent: Config,
}
Expand description
Used to interact with the Prediction Endpoints.
Fields§
§parent: Config
Holds a reference to a Config struct. Use to get the base url, auth token among other settings.
Implementations§
Source§impl Prediction
impl Prediction
Sourcepub fn create<K: Serialize, V: Serialize>(
&self,
version: &str,
inputs: HashMap<K, V>,
) -> Result<PredictionClient, ReplicateError>
pub fn create<K: Serialize, V: Serialize>( &self, version: &str, inputs: HashMap<K, V>, ) -> Result<PredictionClient, ReplicateError>
Create a new prediction, by passing in the model version and inputs to PredictionClient. PredictionClient contains the necessary methods to interact with the prediction such as reload, cancel and wait.
§Example
use replicate_rust::{Replicate, config::Config};
let config = Config::default();
let replicate = Replicate::new(config);
// Construct the inputs.
let mut inputs = std::collections::HashMap::new();
inputs.insert("prompt", "a 19th century portrait of a wombat gentleman");
let version = "stability-ai/stable-diffusion:27b93a2413e7f36cd83da926f3656280b2931564ff050bf9575f1fdf9bcd7478";
// Run the model.
let mut prediction = replicate.predictions.create(version, inputs)?;
println!("Prediction : {:?}", prediction.status);
// Refetch the prediction using the reload method.
prediction.reload();
println!("Prediction : {:?}", prediction.status);
// Wait for the prediction to complete (or fail).
println!("Prediction : {:?}", prediction.wait()?);
Sourcepub fn list(&self) -> Result<ListPredictions, ReplicateError>
pub fn list(&self) -> Result<ListPredictions, ReplicateError>
List all predictions executed in Replicate by the user.
§Example
use replicate_rust::{Replicate, config::Config};
let config = Config::default();
let replicate = Replicate::new(config);
let predictions = replicate.predictions.list()?;
println!("Predictions : {:?}", predictions);
Sourcepub fn get(&self, id: &str) -> Result<GetPrediction, ReplicateError>
pub fn get(&self, id: &str) -> Result<GetPrediction, ReplicateError>
Get a prediction by passing in the prediction id. The prediction id can be obtained from the PredictionClient struct.
§Example
use replicate_rust::{Replicate, config::Config};
let config = Config::default();
let replicate = Replicate::new(config);
let prediction = replicate.predictions.get("rrr4z55ocneqzikepnug6xezpe")?;
println!("Prediction : {:?}", prediction);
Trait Implementations§
Source§impl Clone for Prediction
impl Clone for Prediction
Source§fn clone(&self) -> Prediction
fn clone(&self) -> Prediction
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for Prediction
impl RefUnwindSafe for Prediction
impl Send for Prediction
impl Sync for Prediction
impl Unpin for Prediction
impl UnwindSafe for Prediction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more