1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! A simple http client for interacting with [Replicate](https://replicate.com/).
//! Provides simple async functionality for interacting with Replicate via
//! [serde](https://serde.rs) and [isahc](https://docs.rs/isahc/latest/isahc/).
//!
//! # Getting Started
//!
//! Add the following to your cargo toml
//! ```toml
//! replicate-rs = "0.7.0"
//! ```
//!
//! # Examples
//!
//! #### Create a Prediction
//!
//! Create a prediction, and get refreshed prediction data.
//!
//! ```rust
//! use replicate_rs::config::ReplicateConfig;
//! use replicate_rs::predictions::PredictionClient;
//! use serde::Serialize;
//! use serde_json::json;
//!
//! // The library is runtime agnostic, so you should be able to use any async runtime you please
//! #[tokio::main]
//! async fn main() {
//! tokio::spawn(async move {
//!
//! let config = ReplicateConfig::new().unwrap();
//! let prediction_client = PredictionClient::from(config);
//!
//! // Create the prediction
//! let mut prediction = prediction_client
//! .create(
//! "replicate",
//! "hello-world",
//! json!({"text": "kyle"}),
//! false
//! )
//! .await
//! .unwrap();
//!
//! // Refresh the data
//! prediction.reload().await;
//! });
//! }
//! ```
use crate;
use var;
use OnceLock;