dynamo_async_openai/
steps.rs1use serde::Serialize;
12
13use crate::{
14 Client,
15 config::Config,
16 error::OpenAIError,
17 types::{ListRunStepsResponse, RunStepObject},
18};
19
20pub struct Steps<'c, C: Config> {
22 pub thread_id: String,
23 pub run_id: String,
24 client: &'c Client<C>,
25}
26
27impl<'c, C: Config> Steps<'c, C> {
28 pub fn new(client: &'c Client<C>, thread_id: &str, run_id: &str) -> Self {
29 Self {
30 client,
31 thread_id: thread_id.into(),
32 run_id: run_id.into(),
33 }
34 }
35
36 #[crate::byot(T0 = std::fmt::Display, R = serde::de::DeserializeOwned)]
38 pub async fn retrieve(&self, step_id: &str) -> Result<RunStepObject, OpenAIError> {
39 self.client
40 .get(&format!(
41 "/threads/{}/runs/{}/steps/{step_id}",
42 self.thread_id, self.run_id
43 ))
44 .await
45 }
46
47 #[crate::byot(T0 = serde::Serialize, R = serde::de::DeserializeOwned)]
49 pub async fn list<Q>(&self, query: &Q) -> Result<ListRunStepsResponse, OpenAIError>
50 where
51 Q: Serialize + ?Sized,
52 {
53 self.client
54 .get_with_query(
55 &format!("/threads/{}/runs/{}/steps", self.thread_id, self.run_id),
56 &query,
57 )
58 .await
59 }
60}