Skip to main content

headless_lms_chatbot/chatbot_tools/
tool_category.rs

1//! Which categories of tools a chatbot configuration offers the LLM, independent of
2//! [crate::chatbot_tools::tool_authorization::ToolRequirement]: a category answers "does this
3//! chatbot offer this kind of tool", not "may this caller use it".
4
5use headless_lms_models::chatbot_configurations::{ChatbotConfiguration, ToolCategory};
6
7pub struct EnabledToolCategories(Vec<ToolCategory>);
8
9impl EnabledToolCategories {
10    pub fn from_configuration(configuration: &ChatbotConfiguration) -> Self {
11        Self(configuration.enabled_tool_categories.clone())
12    }
13
14    pub fn contains(&self, category: ToolCategory) -> bool {
15        self.0.contains(&category)
16    }
17
18    pub fn is_empty(&self) -> bool {
19        self.0.is_empty()
20    }
21
22    #[cfg(test)]
23    pub(crate) fn all() -> Self {
24        Self(ToolCategory::ALL.to_vec())
25    }
26
27    #[cfg(test)]
28    pub(crate) fn only(categories: &[ToolCategory]) -> Self {
29        Self(categories.to_vec())
30    }
31}