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
//! A minimal fragment that injects a *static* string into the prompt.
//!
//! Use this when you have pre-determined text (role description, safety
//! notice, system instruction …) that never changes between invocations.
//!
//! ```rust
//! use artificial_types::fragments::StaticFragment;
//! use artificial_core::generic::GenericRole;
//!
//! let sys_msg = StaticFragment::new(
//! "You are a multilingual proof-reading engine.",
//! GenericRole::System,
//! );
//! ```
//!
//! # Why a dedicated type?
//!
//! 1. It keeps the [`IntoPrompt`] API symmetrical – every fragment, no matter
//! how simple, implements the same trait.
//! 2. You can attach metadata (`role`) so the provider sees the correct
//! message type without manual wrapping.
//! 3. Unlike `&'static str`, this struct can carry a *borrowed* slice with
//! lifetime `'a`, allowing the caller to reference larger inline strings
//! without `String` allocation.
//!
//! The `From<&str>` blanket impl defaults to `GenericRole::System` for
//! convenience since system messages are the most common static fragments.
use ;
/// A borrowed static string bundled with an LLM chat role.
///
/// The tuple struct keeps the footprint at *exactly two machine words*
/// (`&str` + `GenericRole`) while still offering ergonomic constructors.
);
/// Shorthand so you can write `StaticFragment::from("…")` without specifying
/// the role each time. Defaults to **system**.