roder_api/thread/
history.rs1use serde::{Deserialize, Serialize};
2use time::OffsetDateTime;
3
4use super::{ThreadItem, ThreadMetadata};
5use crate::events::TurnId;
6use crate::inference::TokenUsage;
7
8#[derive(Debug, Clone)]
10pub struct ThreadHistoryReadOptions {
11 pub before: Option<String>,
12 pub limit: usize,
13 pub max_bytes: usize,
14}
15
16impl Default for ThreadHistoryReadOptions {
17 fn default() -> Self {
18 Self {
19 before: None,
20 limit: 160,
21 max_bytes: 2 * 1024 * 1024,
22 }
23 }
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct ThreadHistoryPage {
28 pub metadata: ThreadMetadata,
29 pub turns: Vec<ThreadHistoryTurn>,
30 pub before: Option<String>,
31 pub has_more: bool,
32}
33
34#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
35#[serde(rename_all = "camelCase")]
36pub enum ThreadHistoryTurnStatus {
37 InProgress,
38 Completed,
39 Failed,
40 Interrupted,
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct ThreadHistoryTurn {
45 pub turn_id: TurnId,
46 #[serde(with = "time::serde::rfc3339")]
47 pub created_at: OffsetDateTime,
48 #[serde(with = "time::serde::rfc3339::option")]
49 pub completed_at: Option<OffsetDateTime>,
50 pub status: ThreadHistoryTurnStatus,
51 pub error: Option<String>,
52 pub usage: Option<TokenUsage>,
53 pub finish_reason: Option<String>,
54 pub items: Vec<ThreadItem>,
55}