telos_agent/agent/prompt/
section.rs1use async_trait::async_trait;
2
3#[derive(Debug, Clone)]
5pub struct PromptBlock {
6 pub name: String,
7 pub text: String,
8 pub stability: PromptStability,
9}
10
11impl PromptBlock {
12 pub fn dynamic(name: impl Into<String>, text: impl Into<String>) -> Self {
13 Self { name: name.into(), text: text.into(), stability: PromptStability::Dynamic }
14 }
15
16 pub fn static_block(name: impl Into<String>, text: impl Into<String>) -> Self {
17 Self { name: name.into(), text: text.into(), stability: PromptStability::Static }
18 }
19}
20
21#[derive(Debug, Clone, Copy, PartialEq, Eq)]
23pub enum CacheHint {
24 Static,
25 Dynamic,
26}
27
28impl From<PromptStability> for CacheHint {
29 fn from(value: PromptStability) -> Self {
30 match value {
31 PromptStability::Static => CacheHint::Static,
32 PromptStability::Dynamic => CacheHint::Dynamic,
33 }
34 }
35}
36
37#[derive(Debug, Clone, Copy, PartialEq, Eq)]
38pub enum PromptStability {
39 Static,
40 Dynamic,
41}
42
43#[async_trait]
44pub trait PromptSection: Send + Sync {
45 fn name(&self) -> &str;
46 fn stability(&self) -> PromptStability;
47 async fn render(&self, _ctx: &()) -> String;
48}
49
50#[async_trait]
51impl PromptSection for Box<dyn PromptSection> {
52 fn name(&self) -> &str {
53 self.as_ref().name()
54 }
55 fn stability(&self) -> PromptStability {
56 self.as_ref().stability()
57 }
58 async fn render(&self, ctx: &()) -> String {
59 self.as_ref().render(ctx).await
60 }
61}