Skip to content

Commit d049e10

Browse files
committed
update doc
1 parent 1d53af4 commit d049e10

2 files changed

Lines changed: 32 additions & 53 deletions

File tree

async-openai/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
119119
<sub>Scaled up for README, actual size 256x256</sub>
120120
</div>
121121

122-
## OpenAI-compatible Providers
122+
## OpenAI Compatible Providers
123123

124124
Even though the scope of the crate is official OpenAI APIs, it is very configurable to work with compatible providers.
125125

@@ -179,7 +179,7 @@ Configure path, headers, and query parameters for a HTTP request.
179179
#### Request Options
180180
Use `path()`, `.query()`, `.header()`, `.headers()` on the API group. Path overrides the default path but all other methods are additive - adds to existing query or headers.
181181

182-
For example:
182+
For demonstration:
183183
```rust
184184
client.
185185
.chat()

async-openai/src/lib.rs

Lines changed: 30 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@
5454
//! # });
5555
//!```
5656
//!
57-
//! ## Bring Your Own Types
57+
//! ## OpenAI Compatible Providers
58+
//!
59+
//! Even though the scope of the crate is official OpenAI APIs, it is very configurable to work with compatible providers.
60+
//!
61+
//! ### Bring Your Own Types
5862
//!
5963
//! To use custom types for inputs and outputs, enable `byot` feature which provides additional generic methods with same name and `_byot` suffix.
6064
//! This feature is available on methods whose return type is not `Bytes`
@@ -109,73 +113,37 @@
109113
//! # });
110114
//! ```
111115
//!
112-
//! ## Rust Types
113-
//!
114-
//! To only use Rust types from the crate - use feature flag `types`.
115-
//!
116-
//! There are granular feature flags like `response-types`, `chat-completion-types`, etc.
116+
//! ### Configurable Requests
117+
//! Configure path, headers, and query parameters for a HTTP request.
117118
//!
118-
//! These granular types are enabled when the corresponding API feature is enabled - for example `responses` will enable `response-types`.
119+
//! **Request Options**
119120
//!
120-
//! ## WASM
121-
//! WASM is supported for all APIs.
122-
//! See [examples/wasm-responses](https://github.com/64bit/async-openai/tree/main/examples/wasm-responses) or [examples/tower-wasm](https://github.com/64bit/async-openai/tree/main/examples/tower-wasm).
121+
//! Use `path()`, `.query()`, `.header()`, `.headers()` on the API group. Path overrides the default path but all other methods are additive - adds to existing query or headers.
123122
//!
124-
//! ## Configurable Requests
125-
//!
126-
//! **Individual Request**
127-
//!
128-
//! Certain individual APIs that need additional query or header parameters - these can be provided by chaining `.query()`, `.header()`, `.headers()` on the API group.
129-
//!
130-
//! For example:
123+
//! For demonstration:
131124
//! ```
132125
//! # tokio_test::block_on(async {
133126
//! # use async_openai::Client;
134127
//! # use async_openai::traits::RequestOptionsBuilder;
135128
//! # let client = Client::new();
136129
//! client
137130
//! .chat()
138-
//! // query can be a struct or a map too.
131+
//! // override default path
132+
//! .path("/v1/messages")
133+
//! // query can be a struct or a map too - additive
139134
//! .query(&[("limit", "10")])?
140-
//! // header for demo
141-
//! .header("key", "value")?
135+
//! // header for unique id for this API request - additive
136+
//! .header("x-request-id", "id123")?
142137
//! .list()
143138
//! .await?;
144139
//! # Ok::<(), Box<dyn std::error::Error>>(())
145140
//! # });
146141
//! ```
147142
//!
148-
//! **All Requests**
143+
//! **Modifying all Requests**
149144
//!
150145
//! Use `Config`, `OpenAIConfig` etc. for configuring url, headers or query parameters globally for all requests.
151146
//!
152-
//! ## OpenAI-compatible Providers
153-
//!
154-
//! Even though the scope of the crate is official OpenAI APIs, it is very configurable to work with compatible providers.
155-
//!
156-
//! **Configurable Path**
157-
//!
158-
//! In addition to `.query()`, `.header()`, `.headers()` a path for individual request can be changed by using `.path()`, method on the API group.
159-
//!
160-
//! For example:
161-
//! ```
162-
//! # tokio_test::block_on(async {
163-
//! # use async_openai::{Client, types::chat::CreateChatCompletionRequestArgs};
164-
//! # use async_openai::traits::RequestOptionsBuilder;
165-
//! # let client = Client::new();
166-
//! # let request = CreateChatCompletionRequestArgs::default()
167-
//! # .model("gpt-4")
168-
//! # .messages([])
169-
//! # .build()
170-
//! # .unwrap();
171-
//! client
172-
//! .chat()
173-
//! .path("/v1/messages")?
174-
//! .create(request)
175-
//! .await?;
176-
//! # Ok::<(), Box<dyn std::error::Error>>(())
177-
//! # });
178-
//! ```
179147
//!
180148
//! **Dynamic Dispatch**
181149
//!
@@ -199,7 +167,7 @@
199167
//! }
200168
//! ```
201169
//!
202-
//! ## Microsoft Azure
170+
//! ### Microsoft Azure
203171
//!
204172
//! ```
205173
//! use async_openai::{Client, config::AzureConfig};
@@ -212,12 +180,23 @@
212180
//!
213181
//! let client = Client::with_config(config);
214182
//!
215-
//! // Note that `async-openai` only implements OpenAI spec
216-
//! // and doesn't maintain parity with the spec of Azure OpenAI service.
217183
//!
218184
//! ```
219185
//!
220186
//!
187+
//! ## Rust Types
188+
//!
189+
//! To only use Rust types from the crate - use feature flag `types`.
190+
//!
191+
//! There are granular feature flags like `response-types`, `chat-completion-types`, etc.
192+
//!
193+
//! These granular types are enabled when the corresponding API feature is enabled - for example `responses` will enable `response-types`.
194+
//!
195+
//! ## WASM
196+
//! WASM is supported for all APIs.
197+
//! See [examples/wasm-responses](https://github.com/64bit/async-openai/tree/main/examples/wasm-responses) or [examples/tower-wasm](https://github.com/64bit/async-openai/tree/main/examples/tower-wasm).
198+
//!
199+
//!
221200
//! ## Middleware
222201
//!
223202
//! Middleware is supported via Tower ecosystem. See [`middleware`] for more detail.

0 commit comments

Comments
 (0)