openai_interface/conversations/
update.rs1use serde::Serialize;
7use url::Url;
8
9use crate::{
10 conversations::Conversation,
11 errors::OapiError,
12 rest::post::{Post, PostNoStream},
13};
14
15#[derive(Debug, Clone, Serialize, Default)]
17pub struct UpdateConversationRequest<'a> {
18 #[serde(skip)]
20 pub conversation_id: &'a str,
21 #[serde(skip_serializing_if = "Option::is_none")]
24 pub metadata: Option<std::collections::HashMap<String, String>>,
25 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
28 pub extra_body_map: Option<serde_json::Map<String, serde_json::Value>>,
29}
30
31impl Post for UpdateConversationRequest<'_> {
32 fn is_streaming(&self) -> bool {
33 false
34 }
35
36 fn build_url(&self, base_url: &str) -> Result<String, OapiError> {
40 let mut url = Url::parse(base_url.trim_end_matches('/')).map_err(OapiError::UrlError)?;
41 url.path_segments_mut()
42 .map_err(|_| OapiError::UrlCannotBeBase(base_url.to_string()))?
43 .push("conversations")
44 .push(self.conversation_id);
45 Ok(url.to_string())
46 }
47}
48
49impl PostNoStream for UpdateConversationRequest<'_> {
50 type Response = Conversation;
51}