aleph_alpha_api/lib.rs
1//! # Inofficial Rust client library for the Aleph Alpha API
2//! Example usage:
3//! ```
4//!use aleph_alpha_api::{error::ApiError, Client, CompletionRequest, LUMINOUS_BASE};
5//!
6//!const AA_API_TOKEN: &str = "<YOUR_AA_API_TOKEN>";
7//!
8//!async fn print_completion() -> Result<(), ApiError> {
9//! let client = Client::new(AA_API_TOKEN.to_owned())?;
10//!
11//! let request =
12//! CompletionRequest::from_text(LUMINOUS_BASE.to_owned(), "An apple a day".to_owned(), 10)
13//! .temperature(0.8)
14//! .top_k(50)
15//! .top_p(0.95)
16//! .best_of(2)
17//! .minimum_tokens(2);
18//!
19//! let response = client.completion(&request, Some(true)).await?;
20//!
21//! println!("An apple a day{}", response.best_text());
22//!
23//! Ok(())
24//!}
25//! ```
26
27mod client;
28mod completion;
29mod embedding;
30pub mod error;
31mod evaluate;
32mod explanation;
33pub mod http;
34pub mod image_processing;
35mod tokenization;
36
37pub const LUMINOUS_BASE: &str = "luminous-base";
38pub const LUMINOUS_BASE_CONTROL: &str = "luminous-base-control";
39pub const LUMINOUS_EXTENDED: &str = "luminous-extended";
40pub const LUMINOUS_EXTENDED_CONTROL: &str = "luminous-extended-control";
41pub const LUMINOUS_SUPREME: &str = "luminous-supreme";
42pub const LUMINOUS_SUPREME_CONTROL: &str = "luminous-supreme-control";
43
44pub use self::{
45 client::Client, client::ALEPH_ALPHA_API_BASE_URL, completion::*, embedding::*, evaluate::*,
46 explanation::*, tokenization::*,
47};
48
49// copied from https://github.com/dongri/openai-api-rs
50#[macro_export]
51macro_rules! impl_builder_methods {
52 ($builder:ident, $($field:ident: $field_type:ty),*) => {
53 impl $builder {
54 $(
55 pub fn $field(mut self, $field: $field_type) -> Self {
56 self.$field = Some($field);
57 self
58 }
59 )*
60 }
61 };
62}