1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//! Simple **builder** that concatenates multiple values implementing
//! [`IntoPrompt`](artificial_core::template::IntoPrompt).
//!
//! ```text
//! ┌───────────────┐ IntoPrompt ┌────────────────┐
//! │ CurrentDate │ ─────────────────►│ Vec<Message> │
//! ├───────────────┤ ├────────────────┤
//! │ StaticFragment│ ─────────────────►│ Vec<Message> │
//! ├───────────────┤ ├────────────────┤
//! │ … │ ─────────────────►│ Vec<Message> │
//! └───────────────┘ └────────────────┘
//! ▲ │
//! └────────── PromptChain::build() ◄────┘
//! ```
//!
//! # Motivation
//!
//! In real-world prompts you often want to **compose** smaller, reusable
//! *fragments*—for example:
//!
//! * a static role description,
//! * the current date/time,
//! * the active user profile,
//! * recent chat history,
//! * a final user instruction.
//!
//! `PromptChain` lets you line up these fragments in a clear, linear fashion
//! **without** mutable vectors or verbose `extend()` calls.
//!
//! # Usage
//!
//! ```rust,ignore
//! use artificial_prompt::chain::PromptChain;
//! use artificial_types::fragments::{CurrentDateFragment, StaticFragment};
//! use artificial_core::generic::{GenericMessage, GenericRole};
//!
//! let messages: Vec<GenericMessage> = PromptChain::new()
//! .with(StaticFragment::new("You are a helpful bot.", GenericRole::System))
//! .with(CurrentDateFragment::new())
//! .with(StaticFragment::new("Convert the text to uppercase.", GenericRole::User))
//! .build();
//!
//! assert_eq!(messages.len(), 3);
//! ```
//!
//! The generic parameter `Message` allows back-ends to plug in their own, richer
//! message types while reusing the same chaining logic.
use IntoPrompt;
/// Lightweight container that accumulates messages produced by
/// [`IntoPrompt`] implementors.
///
/// The single `Vec` field is kept private so the only way to obtain the result
/// is through [`Self::build`], ensuring the builder API remains fluent.
;