Skip to main content

async_openai/
decisions.rs

1use crate::{
2    config::Config,
3    error::OpenAIError,
4    types::decisions::{DecisionRequest, DecisionResponse},
5    Client, RequestOptions,
6};
7
8/// Classify or score inputs using the Decisions API.
9pub struct Decisions<'c, C: Config> {
10    client: &'c Client<C>,
11    pub(crate) request_options: RequestOptions,
12}
13impl<'c, C: Config> Decisions<'c, C> {
14    pub fn new(client: &'c Client<C>) -> Self {
15        Self {
16            client,
17            request_options: RequestOptions::new(),
18        }
19    }
20    /// Answer classification or scoring questions about the input.
21    #[crate::byot(T0 = serde::Serialize, R = serde::de::DeserializeOwned)]
22    pub async fn create(&self, request: DecisionRequest) -> Result<DecisionResponse, OpenAIError> {
23        self.client
24            .post("/decisions", request, &self.request_options)
25            .await
26    }
27}