Skip to content

Commit

Permalink
added initial lib docs
Browse files Browse the repository at this point in the history
  • Loading branch information
KCaverly committed Nov 29, 2023
1 parent f3a64fe commit 65be8c2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{api_key, base_url};
use anyhow::anyhow;

#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct ReplicateClient {
api_key: Option<&'static str>,
base_url: String,
Expand Down
38 changes: 38 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,47 @@
//! 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.2.0"
//! ```
//!
//! # Examples
//!
//! #### Create a Prediction
//!
//! Create a prediction, and get refreshed prediction data.
//!
//! ```rust
//! use replicate_rs::client::ReplicateClient;
//! use replicate_rs::predictions::PredictionClient;
//! use serde::Serialize;
//!
//! let client = ReplicateClient::new()?;
//! let prediction_client = PredictionClient::from(client);
//!
//! #[derive(Serialize)]
//! struct HelloWorldInput {
//! text: "kyle"
//! }
//!
//! // Create the prediction
//! let prediction = prediction_client.create("replicate", "hello-world", prediction_input).await?;
//!
//! // Refresh the data
//! prediction.reload()
//! ```
mod client;
mod models;
mod predictions;

use std::env::var;
use std::sync::OnceLock;

fn api_key() -> anyhow::Result<&'static str> {
let api_key = var("REPLICATE_API_KEY")?;
static REPLICATE_API_KEY: OnceLock<String> = OnceLock::new();
Expand Down

0 comments on commit 65be8c2

Please sign in to comment.