diff --git a/docs/examples/getting-started/Cargo.toml b/docs/examples/getting-started/Cargo.toml deleted file mode 100644 index cf9a7c4..0000000 --- a/docs/examples/getting-started/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "getting-started" -version = "0.1.0" -edition = "2021" - -[dependencies] -instructor-ai = { path = "../../instructor" } -instruct-macros = { path = "../../instruct-macros" } -openai-api-rs = "4.1.0" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -instruct-macros-types = { path = "../../instruct-macros-types" } diff --git a/docs/examples/getting-started/src/main.rs b/docs/examples/getting-started/src/main.rs deleted file mode 100644 index b448578..0000000 --- a/docs/examples/getting-started/src/main.rs +++ /dev/null @@ -1,55 +0,0 @@ -use std::env; - -use instruct_macros::{validate, InstructMacro}; -use instruct_macros_types::{ParameterInfo, StructInfo}; -use instructor_ai::from_openai; -use openai_api_rs::v1::{ - api::Client, - chat_completion::{self, ChatCompletionRequest}, - common::GPT3_5_TURBO, -}; -use serde::{Deserialize, Serialize}; - -fn main() { - let client = Client::new(env::var("OPENAI_API_KEY").unwrap().to_string()); - let instructor_client = from_openai(client); - - #[derive(InstructMacro, Debug, Serialize, Deserialize)] - // This represents a single user - struct UserInfo { - // This represents the name of the user - #[validate(custom = "validate_uppercase")] - name: String, - // This represents the age of the user - age: u8, - } - - #[validate] - fn validate_uppercase(s: &String) -> Result { - if s.chars().any(|c| c.is_lowercase()) { - return Err(format!( - "Name '{}' should be entirely in uppercase. Examples: 'TIMOTHY', 'JANE SMITH'", - s - )); - } - Ok(s.to_uppercase()) - } - - let req = ChatCompletionRequest::new( - GPT3_5_TURBO.to_string(), - vec![chat_completion::ChatCompletionMessage { - role: chat_completion::MessageRole::user, - content: chat_completion::Content::Text(String::from( - "John Doe is a 30 year old software engineer", - )), - name: None, - }], - ); - - let result = instructor_client - .chat_completion::(req, 3) - .unwrap(); - - println!("{}", result.name); // JOHN DOE - println!("{}", result.age); // 30 -} diff --git a/instruct-macros-types/Cargo.toml b/instruct-macros-types/Cargo.toml index c39cb51..4116c4d 100644 --- a/instruct-macros-types/Cargo.toml +++ b/instruct-macros-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "instruct-macros-types" -version = "0.1.2" +version = "0.1.6" edition = "2021" authors = ["Ivan Leo "] description = "Instructor Macro Types are a collection of simple types that we export to work with the instruct-macros crate" diff --git a/instruct-macros/Cargo.toml b/instruct-macros/Cargo.toml index abe119d..1d47d30 100644 --- a/instruct-macros/Cargo.toml +++ b/instruct-macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "instruct-macros" -version = "0.1.1" +version = "0.1.6" edition = "2018" authors = ["Ivan Leo "] description = "instruct-macros are a collection of simple macros that we're using in Instructor-AI to generate json schema from Serde Objects" diff --git a/instructor/Cargo.toml b/instructor/Cargo.toml index 1d29e8b..023854e 100644 --- a/instructor/Cargo.toml +++ b/instructor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "instructor-ai" -version = "0.1.0" +version = "0.1.6" edition = "2021" authors = ["Ivan Leo "] description = "instructor-ai is a simple crate that allows for users to do validated structured outputs"