1use crate::RunObserver;
4use causa_kernel::{CacheDirective, ContextPreparer, GenerationOptions, ModelRef, ProcessorData};
5use std::sync::Arc;
6
7#[derive(Debug, Clone, Copy)]
9#[non_exhaustive]
10pub struct TurnLimits {
11 pub max_model_rounds: u32,
13 pub max_tool_calls: u32,
15}
16impl TurnLimits {
17 pub fn new(max_model_rounds: u32, max_tool_calls: u32) -> Self {
19 Self {
20 max_model_rounds,
21 max_tool_calls,
22 }
23 }
24}
25impl Default for TurnLimits {
26 fn default() -> Self {
27 Self {
28 max_model_rounds: 10,
29 max_tool_calls: 64,
30 }
31 }
32}
33
34#[derive(Clone)]
36#[non_exhaustive]
37pub struct TurnRunOptions {
38 pub model: ModelRef,
40 pub generation: GenerationOptions,
42 pub cache: CacheDirective,
44 pub limits: TurnLimits,
46 pub preparer: Option<Arc<dyn ContextPreparer>>,
48 pub observer: Option<Arc<RunObserver>>,
50 pub processor_data: Option<ProcessorData>,
54}
55impl TurnRunOptions {
56 pub fn new(model: ModelRef) -> Self {
59 Self {
60 model,
61 generation: GenerationOptions::default(),
62 cache: CacheDirective::None,
63 limits: TurnLimits::default(),
64 preparer: None,
65 observer: None,
66 processor_data: None,
67 }
68 }
69
70 pub fn with_generation(mut self, generation: GenerationOptions) -> Self {
72 self.generation = generation;
73 self
74 }
75
76 pub fn with_cache(mut self, cache: CacheDirective) -> Self {
78 self.cache = cache;
79 self
80 }
81
82 pub fn with_limits(mut self, limits: TurnLimits) -> Self {
84 self.limits = limits;
85 self
86 }
87
88 pub fn with_preparer(mut self, preparer: Arc<dyn ContextPreparer>) -> Self {
90 self.preparer = Some(preparer);
91 self
92 }
93
94 pub fn with_observer(mut self, observer: Arc<RunObserver>) -> Self {
96 self.observer = Some(observer);
97 self
98 }
99
100 pub fn with_processor_data(mut self, processor_data: ProcessorData) -> Self {
102 self.processor_data = Some(processor_data);
103 self
104 }
105}