|
| 1 | +//! Pull parser for [CommonMark](https://commonmark.org). This crate provides a [Parser](struct.Parser.html) struct |
| 2 | +//! which is an iterator over [Event](enum.Event.html)s. This iterator can be used |
| 3 | +//! directly, or to output HTML using the [HTML module](html/index.html). |
| 4 | +//! |
| 5 | +//! By default, only CommonMark features are enabled. To use extensions like tables, |
| 6 | +//! footnotes or task lists, enable them by setting the corresponding flags in the |
| 7 | +//! [Options](struct.Options.html) struct. |
| 8 | +//! |
| 9 | +//! # Example |
| 10 | +//! ```rust |
| 11 | +//! use openai_api_rust::*; |
| 12 | +//! use openai_api_rust::chat::*; |
| 13 | +//! use openai_api_rust::completions::*; |
| 14 | +//! |
| 15 | +//! fn main() { |
| 16 | +//! // Load API key from environment OPENAI_API_KEY. |
| 17 | +//! // You can also hadcode through `Auth::new(<your_api_key>)`, but it is not recommended. |
| 18 | +//! let auth = Auth::from_env().unwrap(); |
| 19 | +//! let openai = OpenAI::new(auth, "https://api.openai.com/v1/"); |
| 20 | +//! let body = ChatBody { |
| 21 | +//! model: "gpt-3.5-turbo".to_string(), |
| 22 | +//! max_tokens: Some(7), |
| 23 | +//! temperature: Some(0_f32), |
| 24 | +//! top_p: Some(0_f32), |
| 25 | +//! n: Some(2), |
| 26 | +//! stream: Some(false), |
| 27 | +//! stop: None, |
| 28 | +//! presence_penalty: None, |
| 29 | +//! frequency_penalty: None, |
| 30 | +//! logit_bias: None, |
| 31 | +//! user: None, |
| 32 | +//! messages: vec![Message { role: Role::User, content: "Hello!".to_string() }], |
| 33 | +//! }; |
| 34 | +//! let rs = openai.chat_completion_create(&body); |
| 35 | +//! let choice = rs.unwrap().choices; |
| 36 | +//! let message = &choice[0].message.as_ref().unwrap(); |
| 37 | +//! assert!(message.content.contains("Hello")); |
| 38 | +//! } |
| 39 | +//! ``` |
| 40 | +//! |
| 41 | +//! ## Use proxy |
| 42 | +//! |
| 43 | +//! ```rust |
| 44 | +//! // Load proxy from env |
| 45 | +//! let openai = OpenAI::new(auth, "https://api.openai.com/v1/") |
| 46 | +//! .use_env_proxy(); |
| 47 | +//! |
| 48 | +//! // Set the proxy manually |
| 49 | +//! let openai = OpenAI::new(auth, "https://api.openai.com/v1/") |
| 50 | +//! .set_proxy("http://127.0.0.1:1080"); |
| 51 | +//! ``` |
| 52 | +
|
| 53 | + |
| 54 | + |
1 | 55 | #![warn(unused_crate_dependencies)] |
2 | 56 |
|
3 | 57 | pub mod apis; |
|
0 commit comments