portkey_sdk/model/
threads.rs

1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4
5/// Request to create a thread.
6///
7/// # Example
8///
9/// ```rust,ignore
10/// use portkey::model::CreateThreadRequest;
11///
12/// let request = CreateThreadRequest::builder()
13///     .build()
14///     .unwrap();
15/// ```
16#[derive(Clone, Debug, Default, Serialize, Deserialize)]
17pub struct CreateThreadRequest {
18    /// A list of messages to start the thread with.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub messages: Option<Vec<ThreadMessage>>,
21
22    /// Set of key-value pairs that can be attached to an object.
23    #[serde(skip_serializing_if = "Option::is_none")]
24    pub metadata: Option<HashMap<String, String>>,
25}
26
27/// Modifies a thread.
28#[derive(Clone, Debug, Default, Serialize, Deserialize)]
29pub struct ModifyThreadRequest {
30    /// Set of key-value pairs that can be attached to an object.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub metadata: Option<HashMap<String, String>>,
33}
34
35/// A thread object.
36#[derive(Clone, Debug, Serialize, Deserialize)]
37pub struct Thread {
38    /// The identifier of the thread.
39    pub id: String,
40
41    /// The object type, which is always "thread".
42    pub object: String,
43
44    /// The Unix timestamp (in seconds) for when the thread was created.
45    pub created_at: i64,
46
47    /// Set of key-value pairs that can be attached to an object.
48    pub metadata: HashMap<String, String>,
49}
50
51/// Response from deleting a thread.
52#[derive(Clone, Debug, Serialize, Deserialize)]
53pub struct DeleteThreadResponse {
54    pub id: String,
55    pub object: String,
56    pub deleted: bool,
57}
58
59/// A message in a thread.
60#[derive(Clone, Debug, Serialize, Deserialize)]
61pub struct ThreadMessage {
62    /// The role of the entity that is creating the message.
63    pub role: String,
64
65    /// The content of the message.
66    pub content: String,
67
68    /// A list of File IDs that the message should use.
69    #[serde(skip_serializing_if = "Option::is_none")]
70    pub file_ids: Option<Vec<String>>,
71
72    /// Set of key-value pairs that can be attached to an object.
73    #[serde(skip_serializing_if = "Option::is_none")]
74    pub metadata: Option<HashMap<String, String>>,
75}