Skip to main content

llmrix_rust_sdk/model/
chat.rs

1use serde::{Deserialize, Serialize};
2
3/// Full request body for a chat turn.
4#[derive(Debug, Default, Serialize)]
5pub struct ChatRequest {
6    pub message: String,
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub agent_id: Option<String>,
9    #[serde(skip_serializing_if = "Option::is_none")]
10    pub metadata: Option<serde_json::Value>,
11    #[serde(skip_serializing_if = "Vec::is_empty", default)]
12    pub hitl_decisions: Vec<HitlDecision>,
13}
14
15/// A Human-In-The-Loop decision submitted to resume a paused agent run.
16#[derive(Debug, Clone, Serialize, Deserialize)]
17pub struct HitlDecision {
18    /// `"approve"` | `"reject"` | `"modify"`
19    pub decision: String,
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub reason: Option<String>,
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub modified_args: Option<serde_json::Value>,
24}
25
26impl HitlDecision {
27    /// Approve the pending action.
28    pub fn approve() -> Self {
29        Self { decision: "approve".into(), reason: None, modified_args: None }
30    }
31
32    /// Reject the pending action with an optional reason.
33    pub fn reject(reason: impl Into<String>) -> Self {
34        Self { decision: "reject".into(), reason: Some(reason.into()), modified_args: None }
35    }
36
37    /// Approve with modified arguments.
38    pub fn modify(args: serde_json::Value) -> Self {
39        Self { decision: "modify".into(), reason: None, modified_args: Some(args) }
40    }
41}
42
43/// Wire body for the HITL decide endpoint.
44#[derive(Debug, Serialize)]
45pub(crate) struct HitlDecideRequest {
46    pub decisions: Vec<HitlDecision>,
47}