Skip to main content

lha_core/
input.rs

1use lha_llm::TranscriptItem;
2use lha_llm::types::ContentItem;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum InputQueue {
6    Primary,
7    Steering,
8    FollowUp,
9}
10
11#[derive(Debug, Clone, PartialEq)]
12pub struct SessionInput {
13    items: Vec<TranscriptItem>,
14}
15
16impl SessionInput {
17    pub fn new(items: Vec<TranscriptItem>) -> Self {
18        Self { items }
19    }
20
21    pub fn from_item(item: TranscriptItem) -> Self {
22        Self { items: vec![item] }
23    }
24
25    pub fn from_user_text(text: impl Into<String>) -> Self {
26        Self::from_item(TranscriptItem::Message {
27            id: None,
28            role: "user".to_string(),
29            content: vec![ContentItem::InputText { text: text.into() }],
30            end_turn: None,
31        })
32    }
33
34    pub fn items(&self) -> &[TranscriptItem] {
35        &self.items
36    }
37
38    pub fn into_items(self) -> Vec<TranscriptItem> {
39        self.items
40    }
41}
42
43impl From<Vec<TranscriptItem>> for SessionInput {
44    fn from(value: Vec<TranscriptItem>) -> Self {
45        Self::new(value)
46    }
47}
48
49impl From<TranscriptItem> for SessionInput {
50    fn from(value: TranscriptItem) -> Self {
51        Self::from_item(value)
52    }
53}