Skip to content

Commit

Permalink
Added comments to crate::options module
Browse files Browse the repository at this point in the history
  • Loading branch information
jpalvarezl committed Sep 19, 2024
1 parent f978b9f commit 8eb0b6e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions sdk/openai/inference/src/clients/openai_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub trait OpenAIClientMethods {
fn chat_completions_client(&self) -> ChatCompletionsClient;
}

/// A client that can be used to interact with the OpenAI API.
#[derive(Debug, Clone)]
pub struct OpenAIClient {
base_url: Url,
Expand Down
11 changes: 11 additions & 0 deletions sdk/openai/inference/src/options/azure_openai_client_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use azure_core::ClientOptions;

use crate::AzureServiceVersion;

/// Options to be passed to [`AzureOpenAIClient`](crate::clients::AzureOpenAIClient).
// TODO: I was not able to find ClientOptions as a derive macros
#[derive(Clone, Debug, Default)]
pub struct AzureOpenAIClientOptions {
Expand All @@ -27,11 +28,21 @@ pub mod builders {
pub(super) fn new() -> Self {
Self::default()
}

/// Configures the [`AzureOpenAIClient`](crate::clients::AzureOpenAIClient) to use the specified API version.
/// If no value is supplied, the latest version will be used as default. See [`AzureServiceVersion::get_latest()`](AzureServiceVersion::get_latest).
pub fn with_api_version(mut self, api_service_version: AzureServiceVersion) -> Self {
self.options.api_service_version = api_service_version;
self
}

/// Builds the [`AzureOpenAIClientOptions`].
///
/// # Examples
///
/// ```rust
/// let options = azure_openai_inference::OpenAIClientOptions::builder().build();
/// ```
pub fn build(&self) -> AzureOpenAIClientOptions {
self.options.clone()
}
Expand Down
14 changes: 14 additions & 0 deletions sdk/openai/inference/src/options/openai_client_options.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
use azure_core::ClientOptions;

/// Options to be passed to [`OpenAIClient`](crate::clients::OpenAIClient).
///
/// Note: There are currently no options to be set.
/// This struct is a placeholder for future options.
// TODO: I was not able to find ClientOptions as a derive macros
#[derive(Clone, Debug, Default)]
pub struct OpenAIClientOptions {
pub(crate) client_options: ClientOptions,
}

impl OpenAIClientOptions {
/// Creates a new [`builders::OpenAIClientOptionsBuilder`].
pub fn builder() -> builders::OpenAIClientOptionsBuilder {
builders::OpenAIClientOptionsBuilder::new()
}
}

/// Builder to construct a [`OpenAIClientOptions`].
pub mod builders {
use super::*;

Expand All @@ -24,6 +31,13 @@ pub mod builders {
Self::default()
}

/// Builds the [`OpenAIClientOptions`].
///
/// # Examples
///
/// ```rust
/// let options = azure_openai_inference::OpenAIClientOptions::builder().build();
/// ```
pub fn build(&self) -> OpenAIClientOptions {
self.options.clone()
}
Expand Down
5 changes: 5 additions & 0 deletions sdk/openai/inference/src/options/service_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ use std::sync::Arc;

use azure_core::{Context, Policy, PolicyResult, Request};

/// The version of the Azure service to use.
/// This enum is passed to the [`AzureOpenAIClientOptionsBuilder`](crate::builders::AzureOpenAIClientOptionsBuilder) to configure an [`AzureOpenAIClient`](crate::clients::AzureOpenAIClient) to specify the version of the service to use.
///
/// If no version is specified, the latest version will be used. See [`AzureServiceVersion::get_latest()`](AzureServiceVersion::get_latest).
#[derive(Debug, Clone)]
pub enum AzureServiceVersion {
V2023_09_01Preview,
Expand All @@ -17,6 +21,7 @@ impl Default for AzureServiceVersion {
}

impl AzureServiceVersion {
/// Returns the latest supported version of the Azure OpenAI service.
pub fn get_latest() -> AzureServiceVersion {
AzureServiceVersion::V2024_07_01Preview
}
Expand Down

0 comments on commit 8eb0b6e

Please sign in to comment.