langgraph_api/generated/apis/
threads_api.rs

1/*
2 * LangSmith Deployment
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 0.1.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{ContentType, Error, UploadFile, configuration};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{Deserialize, Serialize, de::Error as _};
15
16/// struct for typed errors of method [`copy_thread_post_threads_thread_id_copy_post`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum CopyThreadPostThreadsThreadIdCopyPostError {
20    Status409(String),
21    Status422(String),
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`count_threads_threads_count_post`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum CountThreadsThreadsCountPostError {
29    Status404(String),
30    Status422(String),
31    UnknownValue(serde_json::Value),
32}
33
34/// struct for typed errors of method [`create_thread_threads_post`]
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum CreateThreadThreadsPostError {
38    Status409(String),
39    Status422(String),
40    UnknownValue(serde_json::Value),
41}
42
43/// struct for typed errors of method [`delete_thread_threads_thread_id_delete`]
44#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(untagged)]
46pub enum DeleteThreadThreadsThreadIdDeleteError {
47    Status404(String),
48    Status422(String),
49    UnknownValue(serde_json::Value),
50}
51
52/// struct for typed errors of method [`get_latest_thread_state_threads_thread_id_state_get`]
53#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum GetLatestThreadStateThreadsThreadIdStateGetError {
56    Status422(String),
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`get_thread_history_post_threads_thread_id_history_post`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum GetThreadHistoryPostThreadsThreadIdHistoryPostError {
64    Status422(String),
65    UnknownValue(serde_json::Value),
66}
67
68/// struct for typed errors of method [`get_thread_history_threads_thread_id_history_get`]
69#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum GetThreadHistoryThreadsThreadIdHistoryGetError {
72    Status422(String),
73    UnknownValue(serde_json::Value),
74}
75
76/// struct for typed errors of method [`get_thread_state_at_checkpoint_threads_thread_id_state_checkpoint_id_get`]
77#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum GetThreadStateAtCheckpointThreadsThreadIdStateCheckpointIdGetError {
80    Status422(String),
81    UnknownValue(serde_json::Value),
82}
83
84/// struct for typed errors of method [`get_thread_threads_thread_id_get`]
85#[derive(Debug, Clone, Serialize, Deserialize)]
86#[serde(untagged)]
87pub enum GetThreadThreadsThreadIdGetError {
88    Status404(String),
89    Status422(String),
90    UnknownValue(serde_json::Value),
91}
92
93/// struct for typed errors of method [`join_thread_stream_threads_thread_id_stream_get`]
94#[derive(Debug, Clone, Serialize, Deserialize)]
95#[serde(untagged)]
96pub enum JoinThreadStreamThreadsThreadIdStreamGetError {
97    Status404(String),
98    Status422(String),
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`patch_thread_threads_thread_id_patch`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum PatchThreadThreadsThreadIdPatchError {
106    Status404(String),
107    Status422(String),
108    UnknownValue(serde_json::Value),
109}
110
111/// struct for typed errors of method [`post_thread_state_at_checkpoint_threads_thread_id_state_checkpoint_id_get`]
112#[derive(Debug, Clone, Serialize, Deserialize)]
113#[serde(untagged)]
114pub enum PostThreadStateAtCheckpointThreadsThreadIdStateCheckpointIdGetError {
115    Status422(String),
116    UnknownValue(serde_json::Value),
117}
118
119/// struct for typed errors of method [`search_threads_threads_search_post`]
120#[derive(Debug, Clone, Serialize, Deserialize)]
121#[serde(untagged)]
122pub enum SearchThreadsThreadsSearchPostError {
123    Status422(String),
124    UnknownValue(serde_json::Value),
125}
126
127/// struct for typed errors of method [`update_thread_state_threads_thread_id_state_post`]
128#[derive(Debug, Clone, Serialize, Deserialize)]
129#[serde(untagged)]
130pub enum UpdateThreadStateThreadsThreadIdStatePostError {
131    Status422(String),
132    UnknownValue(serde_json::Value),
133}
134
135/// Create a new thread with a copy of the state and checkpoints from an existing thread.
136pub fn copy_thread_post_threads_thread_id_copy_post_request_builder(
137    configuration: &configuration::Configuration,
138    thread_id: &str,
139) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
140    // add a prefix to parameters to efficiently prevent name collisions
141    let p_path_thread_id = thread_id;
142
143    let uri_str = format!(
144        "{}/threads/{thread_id}/copy",
145        configuration.base_path,
146        thread_id = crate::apis::urlencode(p_path_thread_id)
147    );
148    let mut req_builder = configuration
149        .client
150        .request(reqwest::Method::POST, &uri_str);
151
152    if let Some(ref user_agent) = configuration.user_agent {
153        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
154    }
155
156    Ok(req_builder)
157}
158
159pub async fn copy_thread_post_threads_thread_id_copy_post(
160    configuration: &configuration::Configuration,
161    thread_id: &str,
162) -> Result<models::Thread, Error<CopyThreadPostThreadsThreadIdCopyPostError>> {
163    let req_builder =
164        copy_thread_post_threads_thread_id_copy_post_request_builder(configuration, thread_id)
165            .map_err(super::map_request_builder_error)?;
166    let req = req_builder.build()?;
167    let resp = configuration.client.execute(req).await?;
168
169    let status = resp.status();
170    let content_type = resp
171        .headers()
172        .get("content-type")
173        .and_then(|v| v.to_str().ok())
174        .unwrap_or("application/octet-stream");
175    let content_type = super::ContentType::from(content_type);
176
177    if !status.is_client_error() && !status.is_server_error() {
178        let content = resp.text().await?;
179        match content_type {
180            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
181            ContentType::Text => Err(Error::from(serde_json::Error::custom(
182                "Received `text/plain` content type response that cannot be converted to `models::Thread`",
183            ))),
184            ContentType::Unsupported(unknown_type) => {
185                Err(Error::from(serde_json::Error::custom(format!(
186                    "Received `{unknown_type}` content type response that cannot be converted to `models::Thread`"
187                ))))
188            }
189        }
190    } else {
191        let content = resp.text().await?;
192        let entity: Option<CopyThreadPostThreadsThreadIdCopyPostError> =
193            serde_json::from_str(&content).ok();
194        Err(Error::ResponseError(ResponseContent {
195            status,
196            content,
197            entity,
198        }))
199    }
200}
201
202/// Get the count of threads matching the specified criteria.
203pub fn count_threads_threads_count_post_request_builder(
204    configuration: &configuration::Configuration,
205    thread_count_request: models::ThreadCountRequest,
206) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
207    // add a prefix to parameters to efficiently prevent name collisions
208    let p_body_thread_count_request = thread_count_request;
209
210    let uri_str = format!("{}/threads/count", configuration.base_path);
211    let mut req_builder = configuration
212        .client
213        .request(reqwest::Method::POST, &uri_str);
214
215    if let Some(ref user_agent) = configuration.user_agent {
216        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
217    }
218    req_builder = req_builder.json(&p_body_thread_count_request);
219
220    Ok(req_builder)
221}
222
223pub async fn count_threads_threads_count_post(
224    configuration: &configuration::Configuration,
225    thread_count_request: models::ThreadCountRequest,
226) -> Result<i32, Error<CountThreadsThreadsCountPostError>> {
227    let req_builder =
228        count_threads_threads_count_post_request_builder(configuration, thread_count_request)
229            .map_err(super::map_request_builder_error)?;
230    let req = req_builder.build()?;
231    let resp = configuration.client.execute(req).await?;
232
233    let status = resp.status();
234    let content_type = resp
235        .headers()
236        .get("content-type")
237        .and_then(|v| v.to_str().ok())
238        .unwrap_or("application/octet-stream");
239    let content_type = super::ContentType::from(content_type);
240
241    if !status.is_client_error() && !status.is_server_error() {
242        let content = resp.text().await?;
243        match content_type {
244            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
245            ContentType::Text => Err(Error::from(serde_json::Error::custom(
246                "Received `text/plain` content type response that cannot be converted to `i32`",
247            ))),
248            ContentType::Unsupported(unknown_type) => {
249                Err(Error::from(serde_json::Error::custom(format!(
250                    "Received `{unknown_type}` content type response that cannot be converted to `i32`"
251                ))))
252            }
253        }
254    } else {
255        let content = resp.text().await?;
256        let entity: Option<CountThreadsThreadsCountPostError> = serde_json::from_str(&content).ok();
257        Err(Error::ResponseError(ResponseContent {
258            status,
259            content,
260            entity,
261        }))
262    }
263}
264
265/// Create a thread.
266pub fn create_thread_threads_post_request_builder(
267    configuration: &configuration::Configuration,
268    thread_create: models::ThreadCreate,
269) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
270    // add a prefix to parameters to efficiently prevent name collisions
271    let p_body_thread_create = thread_create;
272
273    let uri_str = format!("{}/threads", configuration.base_path);
274    let mut req_builder = configuration
275        .client
276        .request(reqwest::Method::POST, &uri_str);
277
278    if let Some(ref user_agent) = configuration.user_agent {
279        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
280    }
281    req_builder = req_builder.json(&p_body_thread_create);
282
283    Ok(req_builder)
284}
285
286pub async fn create_thread_threads_post(
287    configuration: &configuration::Configuration,
288    thread_create: models::ThreadCreate,
289) -> Result<models::Thread, Error<CreateThreadThreadsPostError>> {
290    let req_builder = create_thread_threads_post_request_builder(configuration, thread_create)
291        .map_err(super::map_request_builder_error)?;
292    let req = req_builder.build()?;
293    let resp = configuration.client.execute(req).await?;
294
295    let status = resp.status();
296    let content_type = resp
297        .headers()
298        .get("content-type")
299        .and_then(|v| v.to_str().ok())
300        .unwrap_or("application/octet-stream");
301    let content_type = super::ContentType::from(content_type);
302
303    if !status.is_client_error() && !status.is_server_error() {
304        let content = resp.text().await?;
305        match content_type {
306            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
307            ContentType::Text => Err(Error::from(serde_json::Error::custom(
308                "Received `text/plain` content type response that cannot be converted to `models::Thread`",
309            ))),
310            ContentType::Unsupported(unknown_type) => {
311                Err(Error::from(serde_json::Error::custom(format!(
312                    "Received `{unknown_type}` content type response that cannot be converted to `models::Thread`"
313                ))))
314            }
315        }
316    } else {
317        let content = resp.text().await?;
318        let entity: Option<CreateThreadThreadsPostError> = serde_json::from_str(&content).ok();
319        Err(Error::ResponseError(ResponseContent {
320            status,
321            content,
322            entity,
323        }))
324    }
325}
326
327/// Delete a thread by ID.
328pub fn delete_thread_threads_thread_id_delete_request_builder(
329    configuration: &configuration::Configuration,
330    thread_id: &str,
331) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
332    // add a prefix to parameters to efficiently prevent name collisions
333    let p_path_thread_id = thread_id;
334
335    let uri_str = format!(
336        "{}/threads/{thread_id}",
337        configuration.base_path,
338        thread_id = crate::apis::urlencode(p_path_thread_id)
339    );
340    let mut req_builder = configuration
341        .client
342        .request(reqwest::Method::DELETE, &uri_str);
343
344    if let Some(ref user_agent) = configuration.user_agent {
345        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
346    }
347
348    Ok(req_builder)
349}
350
351pub async fn delete_thread_threads_thread_id_delete(
352    configuration: &configuration::Configuration,
353    thread_id: &str,
354) -> Result<serde_json::Value, Error<DeleteThreadThreadsThreadIdDeleteError>> {
355    let req_builder =
356        delete_thread_threads_thread_id_delete_request_builder(configuration, thread_id)
357            .map_err(super::map_request_builder_error)?;
358    let req = req_builder.build()?;
359    let resp = configuration.client.execute(req).await?;
360
361    let status = resp.status();
362    let content_type = resp
363        .headers()
364        .get("content-type")
365        .and_then(|v| v.to_str().ok())
366        .unwrap_or("application/octet-stream");
367    let content_type = super::ContentType::from(content_type);
368
369    if !status.is_client_error() && !status.is_server_error() {
370        let content = resp.text().await?;
371        match content_type {
372            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
373            ContentType::Text => Err(Error::from(serde_json::Error::custom(
374                "Received `text/plain` content type response that cannot be converted to `serde_json::Value`",
375            ))),
376            ContentType::Unsupported(unknown_type) => {
377                Err(Error::from(serde_json::Error::custom(format!(
378                    "Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`"
379                ))))
380            }
381        }
382    } else {
383        let content = resp.text().await?;
384        let entity: Option<DeleteThreadThreadsThreadIdDeleteError> =
385            serde_json::from_str(&content).ok();
386        Err(Error::ResponseError(ResponseContent {
387            status,
388            content,
389            entity,
390        }))
391    }
392}
393
394/// Get state for a thread.  The latest state of the thread (i.e. latest checkpoint) is returned.
395pub fn get_latest_thread_state_threads_thread_id_state_get_request_builder(
396    configuration: &configuration::Configuration,
397    thread_id: &str,
398    subgraphs: Option<bool>,
399) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
400    // add a prefix to parameters to efficiently prevent name collisions
401    let p_path_thread_id = thread_id;
402    let p_query_subgraphs = subgraphs;
403
404    let uri_str = format!(
405        "{}/threads/{thread_id}/state",
406        configuration.base_path,
407        thread_id = crate::apis::urlencode(p_path_thread_id)
408    );
409    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
410
411    if let Some(ref param_value) = p_query_subgraphs {
412        req_builder = req_builder.query(&[("subgraphs", &param_value.to_string())]);
413    }
414    if let Some(ref user_agent) = configuration.user_agent {
415        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
416    }
417
418    Ok(req_builder)
419}
420
421pub async fn get_latest_thread_state_threads_thread_id_state_get(
422    configuration: &configuration::Configuration,
423    thread_id: &str,
424    subgraphs: Option<bool>,
425) -> Result<models::ThreadState, Error<GetLatestThreadStateThreadsThreadIdStateGetError>> {
426    let req_builder = get_latest_thread_state_threads_thread_id_state_get_request_builder(
427        configuration,
428        thread_id,
429        subgraphs,
430    )
431    .map_err(super::map_request_builder_error)?;
432    let req = req_builder.build()?;
433    let resp = configuration.client.execute(req).await?;
434
435    let status = resp.status();
436    let content_type = resp
437        .headers()
438        .get("content-type")
439        .and_then(|v| v.to_str().ok())
440        .unwrap_or("application/octet-stream");
441    let content_type = super::ContentType::from(content_type);
442
443    if !status.is_client_error() && !status.is_server_error() {
444        let content = resp.text().await?;
445        match content_type {
446            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
447            ContentType::Text => Err(Error::from(serde_json::Error::custom(
448                "Received `text/plain` content type response that cannot be converted to `models::ThreadState`",
449            ))),
450            ContentType::Unsupported(unknown_type) => {
451                Err(Error::from(serde_json::Error::custom(format!(
452                    "Received `{unknown_type}` content type response that cannot be converted to `models::ThreadState`"
453                ))))
454            }
455        }
456    } else {
457        let content = resp.text().await?;
458        let entity: Option<GetLatestThreadStateThreadsThreadIdStateGetError> =
459            serde_json::from_str(&content).ok();
460        Err(Error::ResponseError(ResponseContent {
461            status,
462            content,
463            entity,
464        }))
465    }
466}
467
468/// Get all past states for a thread.
469pub fn get_thread_history_post_threads_thread_id_history_post_request_builder(
470    configuration: &configuration::Configuration,
471    thread_id: &str,
472    thread_state_search: models::ThreadStateSearch,
473) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
474    // add a prefix to parameters to efficiently prevent name collisions
475    let p_path_thread_id = thread_id;
476    let p_body_thread_state_search = thread_state_search;
477
478    let uri_str = format!(
479        "{}/threads/{thread_id}/history",
480        configuration.base_path,
481        thread_id = crate::apis::urlencode(p_path_thread_id)
482    );
483    let mut req_builder = configuration
484        .client
485        .request(reqwest::Method::POST, &uri_str);
486
487    if let Some(ref user_agent) = configuration.user_agent {
488        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
489    }
490    req_builder = req_builder.json(&p_body_thread_state_search);
491
492    Ok(req_builder)
493}
494
495pub async fn get_thread_history_post_threads_thread_id_history_post(
496    configuration: &configuration::Configuration,
497    thread_id: &str,
498    thread_state_search: models::ThreadStateSearch,
499) -> Result<Vec<models::ThreadState>, Error<GetThreadHistoryPostThreadsThreadIdHistoryPostError>> {
500    let req_builder = get_thread_history_post_threads_thread_id_history_post_request_builder(
501        configuration,
502        thread_id,
503        thread_state_search,
504    )
505    .map_err(super::map_request_builder_error)?;
506    let req = req_builder.build()?;
507    let resp = configuration.client.execute(req).await?;
508
509    let status = resp.status();
510    let content_type = resp
511        .headers()
512        .get("content-type")
513        .and_then(|v| v.to_str().ok())
514        .unwrap_or("application/octet-stream");
515    let content_type = super::ContentType::from(content_type);
516
517    if !status.is_client_error() && !status.is_server_error() {
518        let content = resp.text().await?;
519        match content_type {
520            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
521            ContentType::Text => Err(Error::from(serde_json::Error::custom(
522                "Received `text/plain` content type response that cannot be converted to `Vec&lt;models::ThreadState&gt;`",
523            ))),
524            ContentType::Unsupported(unknown_type) => {
525                Err(Error::from(serde_json::Error::custom(format!(
526                    "Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::ThreadState&gt;`"
527                ))))
528            }
529        }
530    } else {
531        let content = resp.text().await?;
532        let entity: Option<GetThreadHistoryPostThreadsThreadIdHistoryPostError> =
533            serde_json::from_str(&content).ok();
534        Err(Error::ResponseError(ResponseContent {
535            status,
536            content,
537            entity,
538        }))
539    }
540}
541
542/// Get all past states for a thread.
543pub fn get_thread_history_threads_thread_id_history_get_request_builder(
544    configuration: &configuration::Configuration,
545    thread_id: &str,
546    limit: Option<i32>,
547    before: Option<&str>,
548) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
549    // add a prefix to parameters to efficiently prevent name collisions
550    let p_path_thread_id = thread_id;
551    let p_query_limit = limit;
552    let p_query_before = before;
553
554    let uri_str = format!(
555        "{}/threads/{thread_id}/history",
556        configuration.base_path,
557        thread_id = crate::apis::urlencode(p_path_thread_id)
558    );
559    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
560
561    if let Some(ref param_value) = p_query_limit {
562        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
563    }
564    if let Some(ref param_value) = p_query_before {
565        req_builder = req_builder.query(&[("before", &param_value.to_string())]);
566    }
567    if let Some(ref user_agent) = configuration.user_agent {
568        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
569    }
570
571    Ok(req_builder)
572}
573
574pub async fn get_thread_history_threads_thread_id_history_get(
575    configuration: &configuration::Configuration,
576    thread_id: &str,
577    limit: Option<i32>,
578    before: Option<&str>,
579) -> Result<Vec<models::ThreadState>, Error<GetThreadHistoryThreadsThreadIdHistoryGetError>> {
580    let req_builder = get_thread_history_threads_thread_id_history_get_request_builder(
581        configuration,
582        thread_id,
583        limit,
584        before,
585    )
586    .map_err(super::map_request_builder_error)?;
587    let req = req_builder.build()?;
588    let resp = configuration.client.execute(req).await?;
589
590    let status = resp.status();
591    let content_type = resp
592        .headers()
593        .get("content-type")
594        .and_then(|v| v.to_str().ok())
595        .unwrap_or("application/octet-stream");
596    let content_type = super::ContentType::from(content_type);
597
598    if !status.is_client_error() && !status.is_server_error() {
599        let content = resp.text().await?;
600        match content_type {
601            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
602            ContentType::Text => Err(Error::from(serde_json::Error::custom(
603                "Received `text/plain` content type response that cannot be converted to `Vec&lt;models::ThreadState&gt;`",
604            ))),
605            ContentType::Unsupported(unknown_type) => {
606                Err(Error::from(serde_json::Error::custom(format!(
607                    "Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::ThreadState&gt;`"
608                ))))
609            }
610        }
611    } else {
612        let content = resp.text().await?;
613        let entity: Option<GetThreadHistoryThreadsThreadIdHistoryGetError> =
614            serde_json::from_str(&content).ok();
615        Err(Error::ResponseError(ResponseContent {
616            status,
617            content,
618            entity,
619        }))
620    }
621}
622
623/// Get state for a thread at a specific checkpoint.
624pub fn get_thread_state_at_checkpoint_threads_thread_id_state_checkpoint_id_get_request_builder(
625    configuration: &configuration::Configuration,
626    thread_id: &str,
627    checkpoint_id: &str,
628    subgraphs: Option<bool>,
629) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
630    // add a prefix to parameters to efficiently prevent name collisions
631    let p_path_thread_id = thread_id;
632    let p_path_checkpoint_id = checkpoint_id;
633    let p_query_subgraphs = subgraphs;
634
635    let uri_str = format!(
636        "{}/threads/{thread_id}/state/{checkpoint_id}",
637        configuration.base_path,
638        thread_id = crate::apis::urlencode(p_path_thread_id),
639        checkpoint_id = crate::apis::urlencode(p_path_checkpoint_id)
640    );
641    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
642
643    if let Some(ref param_value) = p_query_subgraphs {
644        req_builder = req_builder.query(&[("subgraphs", &param_value.to_string())]);
645    }
646    if let Some(ref user_agent) = configuration.user_agent {
647        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
648    }
649
650    Ok(req_builder)
651}
652
653pub async fn get_thread_state_at_checkpoint_threads_thread_id_state_checkpoint_id_get(
654    configuration: &configuration::Configuration,
655    thread_id: &str,
656    checkpoint_id: &str,
657    subgraphs: Option<bool>,
658) -> Result<
659    models::ThreadState,
660    Error<GetThreadStateAtCheckpointThreadsThreadIdStateCheckpointIdGetError>,
661> {
662    let req_builder =
663        get_thread_state_at_checkpoint_threads_thread_id_state_checkpoint_id_get_request_builder(
664            configuration,
665            thread_id,
666            checkpoint_id,
667            subgraphs,
668        )
669        .map_err(super::map_request_builder_error)?;
670    let req = req_builder.build()?;
671    let resp = configuration.client.execute(req).await?;
672
673    let status = resp.status();
674    let content_type = resp
675        .headers()
676        .get("content-type")
677        .and_then(|v| v.to_str().ok())
678        .unwrap_or("application/octet-stream");
679    let content_type = super::ContentType::from(content_type);
680
681    if !status.is_client_error() && !status.is_server_error() {
682        let content = resp.text().await?;
683        match content_type {
684            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
685            ContentType::Text => Err(Error::from(serde_json::Error::custom(
686                "Received `text/plain` content type response that cannot be converted to `models::ThreadState`",
687            ))),
688            ContentType::Unsupported(unknown_type) => {
689                Err(Error::from(serde_json::Error::custom(format!(
690                    "Received `{unknown_type}` content type response that cannot be converted to `models::ThreadState`"
691                ))))
692            }
693        }
694    } else {
695        let content = resp.text().await?;
696        let entity: Option<GetThreadStateAtCheckpointThreadsThreadIdStateCheckpointIdGetError> =
697            serde_json::from_str(&content).ok();
698        Err(Error::ResponseError(ResponseContent {
699            status,
700            content,
701            entity,
702        }))
703    }
704}
705
706/// Get a thread by ID.
707pub fn get_thread_threads_thread_id_get_request_builder(
708    configuration: &configuration::Configuration,
709    thread_id: &str,
710) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
711    // add a prefix to parameters to efficiently prevent name collisions
712    let p_path_thread_id = thread_id;
713
714    let uri_str = format!(
715        "{}/threads/{thread_id}",
716        configuration.base_path,
717        thread_id = crate::apis::urlencode(p_path_thread_id)
718    );
719    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
720
721    if let Some(ref user_agent) = configuration.user_agent {
722        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
723    }
724
725    Ok(req_builder)
726}
727
728pub async fn get_thread_threads_thread_id_get(
729    configuration: &configuration::Configuration,
730    thread_id: &str,
731) -> Result<models::Thread, Error<GetThreadThreadsThreadIdGetError>> {
732    let req_builder = get_thread_threads_thread_id_get_request_builder(configuration, thread_id)
733        .map_err(super::map_request_builder_error)?;
734    let req = req_builder.build()?;
735    let resp = configuration.client.execute(req).await?;
736
737    let status = resp.status();
738    let content_type = resp
739        .headers()
740        .get("content-type")
741        .and_then(|v| v.to_str().ok())
742        .unwrap_or("application/octet-stream");
743    let content_type = super::ContentType::from(content_type);
744
745    if !status.is_client_error() && !status.is_server_error() {
746        let content = resp.text().await?;
747        match content_type {
748            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
749            ContentType::Text => Err(Error::from(serde_json::Error::custom(
750                "Received `text/plain` content type response that cannot be converted to `models::Thread`",
751            ))),
752            ContentType::Unsupported(unknown_type) => {
753                Err(Error::from(serde_json::Error::custom(format!(
754                    "Received `{unknown_type}` content type response that cannot be converted to `models::Thread`"
755                ))))
756            }
757        }
758    } else {
759        let content = resp.text().await?;
760        let entity: Option<GetThreadThreadsThreadIdGetError> = serde_json::from_str(&content).ok();
761        Err(Error::ResponseError(ResponseContent {
762            status,
763            content,
764            entity,
765        }))
766    }
767}
768
769/// This endpoint streams output in real-time from a thread. The stream will include the output of each run executed sequentially on the thread and will remain open indefinitely. It is the responsibility of the calling client to close the connection.
770pub fn join_thread_stream_threads_thread_id_stream_get_request_builder(
771    configuration: &configuration::Configuration,
772    thread_id: &str,
773    last_event_id: Option<&str>,
774    stream_modes: Option<&str>,
775) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
776    // add a prefix to parameters to efficiently prevent name collisions
777    let p_path_thread_id = thread_id;
778    let p_header_last_event_id = last_event_id;
779    let p_query_stream_modes = stream_modes;
780
781    let uri_str = format!(
782        "{}/threads/{thread_id}/stream",
783        configuration.base_path,
784        thread_id = crate::apis::urlencode(p_path_thread_id)
785    );
786    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
787
788    if let Some(ref param_value) = p_query_stream_modes {
789        req_builder = req_builder.query(&[("stream_modes", &serde_json::to_string(param_value)?)]);
790    }
791    if let Some(ref user_agent) = configuration.user_agent {
792        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
793    }
794    if let Some(param_value) = p_header_last_event_id {
795        req_builder = req_builder.header("Last-Event-ID", param_value.to_string());
796    }
797
798    Ok(req_builder)
799}
800
801pub async fn join_thread_stream_threads_thread_id_stream_get(
802    configuration: &configuration::Configuration,
803    thread_id: &str,
804    last_event_id: Option<&str>,
805    stream_modes: Option<&str>,
806) -> Result<String, Error<JoinThreadStreamThreadsThreadIdStreamGetError>> {
807    let req_builder = join_thread_stream_threads_thread_id_stream_get_request_builder(
808        configuration,
809        thread_id,
810        last_event_id,
811        stream_modes,
812    )
813    .map_err(super::map_request_builder_error)?;
814    let req = req_builder.build()?;
815    let resp = configuration.client.execute(req).await?;
816
817    let status = resp.status();
818    let content_type = resp
819        .headers()
820        .get("content-type")
821        .and_then(|v| v.to_str().ok())
822        .unwrap_or("application/octet-stream");
823    let content_type = super::ContentType::from(content_type);
824
825    if !status.is_client_error() && !status.is_server_error() {
826        let content = resp.text().await?;
827        match content_type {
828            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
829            ContentType::Text => Err(Error::from(serde_json::Error::custom(
830                "Received `text/plain` content type response that cannot be converted to `String`",
831            ))),
832            ContentType::Unsupported(unknown_type) => {
833                Err(Error::from(serde_json::Error::custom(format!(
834                    "Received `{unknown_type}` content type response that cannot be converted to `String`"
835                ))))
836            }
837        }
838    } else {
839        let content = resp.text().await?;
840        let entity: Option<JoinThreadStreamThreadsThreadIdStreamGetError> =
841            serde_json::from_str(&content).ok();
842        Err(Error::ResponseError(ResponseContent {
843            status,
844            content,
845            entity,
846        }))
847    }
848}
849
850/// Update a thread.
851pub fn patch_thread_threads_thread_id_patch_request_builder(
852    configuration: &configuration::Configuration,
853    thread_id: &str,
854    thread_patch: models::ThreadPatch,
855) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
856    // add a prefix to parameters to efficiently prevent name collisions
857    let p_path_thread_id = thread_id;
858    let p_body_thread_patch = thread_patch;
859
860    let uri_str = format!(
861        "{}/threads/{thread_id}",
862        configuration.base_path,
863        thread_id = crate::apis::urlencode(p_path_thread_id)
864    );
865    let mut req_builder = configuration
866        .client
867        .request(reqwest::Method::PATCH, &uri_str);
868
869    if let Some(ref user_agent) = configuration.user_agent {
870        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
871    }
872    req_builder = req_builder.json(&p_body_thread_patch);
873
874    Ok(req_builder)
875}
876
877pub async fn patch_thread_threads_thread_id_patch(
878    configuration: &configuration::Configuration,
879    thread_id: &str,
880    thread_patch: models::ThreadPatch,
881) -> Result<models::Thread, Error<PatchThreadThreadsThreadIdPatchError>> {
882    let req_builder = patch_thread_threads_thread_id_patch_request_builder(
883        configuration,
884        thread_id,
885        thread_patch,
886    )
887    .map_err(super::map_request_builder_error)?;
888    let req = req_builder.build()?;
889    let resp = configuration.client.execute(req).await?;
890
891    let status = resp.status();
892    let content_type = resp
893        .headers()
894        .get("content-type")
895        .and_then(|v| v.to_str().ok())
896        .unwrap_or("application/octet-stream");
897    let content_type = super::ContentType::from(content_type);
898
899    if !status.is_client_error() && !status.is_server_error() {
900        let content = resp.text().await?;
901        match content_type {
902            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
903            ContentType::Text => Err(Error::from(serde_json::Error::custom(
904                "Received `text/plain` content type response that cannot be converted to `models::Thread`",
905            ))),
906            ContentType::Unsupported(unknown_type) => {
907                Err(Error::from(serde_json::Error::custom(format!(
908                    "Received `{unknown_type}` content type response that cannot be converted to `models::Thread`"
909                ))))
910            }
911        }
912    } else {
913        let content = resp.text().await?;
914        let entity: Option<PatchThreadThreadsThreadIdPatchError> =
915            serde_json::from_str(&content).ok();
916        Err(Error::ResponseError(ResponseContent {
917            status,
918            content,
919            entity,
920        }))
921    }
922}
923
924/// Get state for a thread at a specific checkpoint.
925pub fn post_thread_state_at_checkpoint_threads_thread_id_state_checkpoint_id_get_request_builder(
926    configuration: &configuration::Configuration,
927    thread_id: &str,
928    thread_state_checkpoint_request: models::ThreadStateCheckpointRequest,
929    subgraphs: Option<bool>,
930) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
931    // add a prefix to parameters to efficiently prevent name collisions
932    let p_path_thread_id = thread_id;
933    let p_body_thread_state_checkpoint_request = thread_state_checkpoint_request;
934    let p_query_subgraphs = subgraphs;
935
936    let uri_str = format!(
937        "{}/threads/{thread_id}/state/checkpoint",
938        configuration.base_path,
939        thread_id = crate::apis::urlencode(p_path_thread_id)
940    );
941    let mut req_builder = configuration
942        .client
943        .request(reqwest::Method::POST, &uri_str);
944
945    if let Some(ref param_value) = p_query_subgraphs {
946        req_builder = req_builder.query(&[("subgraphs", &param_value.to_string())]);
947    }
948    if let Some(ref user_agent) = configuration.user_agent {
949        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
950    }
951    req_builder = req_builder.json(&p_body_thread_state_checkpoint_request);
952
953    Ok(req_builder)
954}
955
956pub async fn post_thread_state_at_checkpoint_threads_thread_id_state_checkpoint_id_get(
957    configuration: &configuration::Configuration,
958    thread_id: &str,
959    thread_state_checkpoint_request: models::ThreadStateCheckpointRequest,
960    subgraphs: Option<bool>,
961) -> Result<
962    models::ThreadState,
963    Error<PostThreadStateAtCheckpointThreadsThreadIdStateCheckpointIdGetError>,
964> {
965    let req_builder =
966        post_thread_state_at_checkpoint_threads_thread_id_state_checkpoint_id_get_request_builder(
967            configuration,
968            thread_id,
969            thread_state_checkpoint_request,
970            subgraphs,
971        )
972        .map_err(super::map_request_builder_error)?;
973    let req = req_builder.build()?;
974    let resp = configuration.client.execute(req).await?;
975
976    let status = resp.status();
977    let content_type = resp
978        .headers()
979        .get("content-type")
980        .and_then(|v| v.to_str().ok())
981        .unwrap_or("application/octet-stream");
982    let content_type = super::ContentType::from(content_type);
983
984    if !status.is_client_error() && !status.is_server_error() {
985        let content = resp.text().await?;
986        match content_type {
987            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
988            ContentType::Text => Err(Error::from(serde_json::Error::custom(
989                "Received `text/plain` content type response that cannot be converted to `models::ThreadState`",
990            ))),
991            ContentType::Unsupported(unknown_type) => {
992                Err(Error::from(serde_json::Error::custom(format!(
993                    "Received `{unknown_type}` content type response that cannot be converted to `models::ThreadState`"
994                ))))
995            }
996        }
997    } else {
998        let content = resp.text().await?;
999        let entity: Option<PostThreadStateAtCheckpointThreadsThreadIdStateCheckpointIdGetError> =
1000            serde_json::from_str(&content).ok();
1001        Err(Error::ResponseError(ResponseContent {
1002            status,
1003            content,
1004            entity,
1005        }))
1006    }
1007}
1008
1009/// Search for threads.  This endpoint also functions as the endpoint to list all threads.
1010pub fn search_threads_threads_search_post_request_builder(
1011    configuration: &configuration::Configuration,
1012    thread_search_request: models::ThreadSearchRequest,
1013) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
1014    // add a prefix to parameters to efficiently prevent name collisions
1015    let p_body_thread_search_request = thread_search_request;
1016
1017    let uri_str = format!("{}/threads/search", configuration.base_path);
1018    let mut req_builder = configuration
1019        .client
1020        .request(reqwest::Method::POST, &uri_str);
1021
1022    if let Some(ref user_agent) = configuration.user_agent {
1023        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1024    }
1025    req_builder = req_builder.json(&p_body_thread_search_request);
1026
1027    Ok(req_builder)
1028}
1029
1030pub async fn search_threads_threads_search_post(
1031    configuration: &configuration::Configuration,
1032    thread_search_request: models::ThreadSearchRequest,
1033) -> Result<Vec<models::Thread>, Error<SearchThreadsThreadsSearchPostError>> {
1034    let req_builder =
1035        search_threads_threads_search_post_request_builder(configuration, thread_search_request)
1036            .map_err(super::map_request_builder_error)?;
1037    let req = req_builder.build()?;
1038    let resp = configuration.client.execute(req).await?;
1039
1040    let status = resp.status();
1041    let content_type = resp
1042        .headers()
1043        .get("content-type")
1044        .and_then(|v| v.to_str().ok())
1045        .unwrap_or("application/octet-stream");
1046    let content_type = super::ContentType::from(content_type);
1047
1048    if !status.is_client_error() && !status.is_server_error() {
1049        let content = resp.text().await?;
1050        match content_type {
1051            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1052            ContentType::Text => Err(Error::from(serde_json::Error::custom(
1053                "Received `text/plain` content type response that cannot be converted to `Vec&lt;models::Thread&gt;`",
1054            ))),
1055            ContentType::Unsupported(unknown_type) => {
1056                Err(Error::from(serde_json::Error::custom(format!(
1057                    "Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::Thread&gt;`"
1058                ))))
1059            }
1060        }
1061    } else {
1062        let content = resp.text().await?;
1063        let entity: Option<SearchThreadsThreadsSearchPostError> =
1064            serde_json::from_str(&content).ok();
1065        Err(Error::ResponseError(ResponseContent {
1066            status,
1067            content,
1068            entity,
1069        }))
1070    }
1071}
1072
1073/// Add state to a thread.
1074pub fn update_thread_state_threads_thread_id_state_post_request_builder(
1075    configuration: &configuration::Configuration,
1076    thread_id: &str,
1077    thread_state_update: models::ThreadStateUpdate,
1078) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
1079    // add a prefix to parameters to efficiently prevent name collisions
1080    let p_path_thread_id = thread_id;
1081    let p_body_thread_state_update = thread_state_update;
1082
1083    let uri_str = format!(
1084        "{}/threads/{thread_id}/state",
1085        configuration.base_path,
1086        thread_id = crate::apis::urlencode(p_path_thread_id)
1087    );
1088    let mut req_builder = configuration
1089        .client
1090        .request(reqwest::Method::POST, &uri_str);
1091
1092    if let Some(ref user_agent) = configuration.user_agent {
1093        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1094    }
1095    req_builder = req_builder.json(&p_body_thread_state_update);
1096
1097    Ok(req_builder)
1098}
1099
1100pub async fn update_thread_state_threads_thread_id_state_post(
1101    configuration: &configuration::Configuration,
1102    thread_id: &str,
1103    thread_state_update: models::ThreadStateUpdate,
1104) -> Result<models::ThreadStateUpdateResponse, Error<UpdateThreadStateThreadsThreadIdStatePostError>>
1105{
1106    let req_builder = update_thread_state_threads_thread_id_state_post_request_builder(
1107        configuration,
1108        thread_id,
1109        thread_state_update,
1110    )
1111    .map_err(super::map_request_builder_error)?;
1112    let req = req_builder.build()?;
1113    let resp = configuration.client.execute(req).await?;
1114
1115    let status = resp.status();
1116    let content_type = resp
1117        .headers()
1118        .get("content-type")
1119        .and_then(|v| v.to_str().ok())
1120        .unwrap_or("application/octet-stream");
1121    let content_type = super::ContentType::from(content_type);
1122
1123    if !status.is_client_error() && !status.is_server_error() {
1124        let content = resp.text().await?;
1125        match content_type {
1126            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1127            ContentType::Text => Err(Error::from(serde_json::Error::custom(
1128                "Received `text/plain` content type response that cannot be converted to `models::ThreadStateUpdateResponse`",
1129            ))),
1130            ContentType::Unsupported(unknown_type) => {
1131                Err(Error::from(serde_json::Error::custom(format!(
1132                    "Received `{unknown_type}` content type response that cannot be converted to `models::ThreadStateUpdateResponse`"
1133                ))))
1134            }
1135        }
1136    } else {
1137        let content = resp.text().await?;
1138        let entity: Option<UpdateThreadStateThreadsThreadIdStatePostError> =
1139            serde_json::from_str(&content).ok();
1140        Err(Error::ResponseError(ResponseContent {
1141            status,
1142            content,
1143            entity,
1144        }))
1145    }
1146}