pub struct TerraphimService { /* private fields */ }Implementations§
Source§impl TerraphimService
impl TerraphimService
Sourcepub fn new(config_state: ConfigState) -> Self
pub fn new(config_state: ConfigState) -> Self
Create a new TerraphimService
Sourcepub async fn ensure_thesaurus_loaded(
&mut self,
role_name: &RoleName,
) -> Result<Thesaurus>
pub async fn ensure_thesaurus_loaded( &mut self, role_name: &RoleName, ) -> Result<Thesaurus>
load thesaurus from config object and if absent make sure it’s loaded from automata_url
Sourcepub async fn preprocess_document_content(
&mut self,
document: Document,
role: &Role,
) -> Result<Document>
pub async fn preprocess_document_content( &mut self, document: Document, role: &Role, ) -> Result<Document>
Preprocess document content to create clickable KG links when terraphim_it is enabled
This function replaces KG terms in the document body with markdown links in the format term which can be intercepted by the frontend to display KG documents when clicked.
Sourcepub async fn preprocess_document_content_with_search(
&mut self,
document: Document,
role: &Role,
search_query: Option<&SearchQuery>,
) -> Result<Document>
pub async fn preprocess_document_content_with_search( &mut self, document: Document, role: &Role, search_query: Option<&SearchQuery>, ) -> Result<Document>
Preprocess document content with both KG linking and search term highlighting
Sourcepub async fn create_document(&mut self, document: Document) -> Result<Document>
pub async fn create_document(&mut self, document: Document) -> Result<Document>
Create document
Sourcepub async fn get_document_by_id(
&mut self,
document_id: &str,
) -> Result<Option<Document>>
pub async fn get_document_by_id( &mut self, document_id: &str, ) -> Result<Option<Document>>
Get document by ID
This method supports both normalized IDs (e.g., “haystackmd”) and original filenames (e.g., “haystack.md”). It tries to find the document using the provided ID first, then tries with a normalized version, and finally falls back to searching by title.
Sourcepub async fn apply_logical_operators_to_documents(
&mut self,
search_query: &SearchQuery,
documents: Vec<Document>,
) -> Result<Vec<Document>>
pub async fn apply_logical_operators_to_documents( &mut self, search_query: &SearchQuery, documents: Vec<Document>, ) -> Result<Vec<Document>>
Apply logical operators (AND/OR) to filter documents based on multiple search terms
Sourcepub async fn search_documents_selected_role(
&mut self,
search_term: &NormalizedTermValue,
) -> Result<Vec<Document>>
pub async fn search_documents_selected_role( &mut self, search_term: &NormalizedTermValue, ) -> Result<Vec<Document>>
search for documents in the haystacks with selected role from the config and return the documents sorted by relevance
Sourcepub async fn search(
&mut self,
search_query: &SearchQuery,
) -> Result<Vec<Document>>
pub async fn search( &mut self, search_query: &SearchQuery, ) -> Result<Vec<Document>>
Search for documents in the haystacks
Sourcepub async fn find_documents_for_kg_term(
&mut self,
role_name: &RoleName,
term: &str,
) -> Result<Vec<Document>>
pub async fn find_documents_for_kg_term( &mut self, role_name: &RoleName, term: &str, ) -> Result<Vec<Document>>
Find documents that contain a given knowledge graph term
This method searches for documents that were the source of a knowledge graph term. For example, given “haystack”, it will find documents like “haystack.md” that contain this term or its synonyms (“datasource”, “service”, “agent”).
For KG protocol resolution, this method also directly looks for KG definition documents when the term appears to be a KG concept (like “terraphim-graph” -> “./docs/src/kg/terraphim-graph.md”).
Returns a vector of Documents that contain the term, with KG preprocessing applied if enabled for the role.
Sourcepub async fn generate_document_summary(
&self,
_document: &Document,
_api_key: &str,
_model: &str,
_max_length: usize,
) -> Result<String>
pub async fn generate_document_summary( &self, _document: &Document, _api_key: &str, _model: &str, _max_length: usize, ) -> Result<String>
Generate a summary for a document using OpenRouter (stub when feature is disabled)
Sourcepub async fn fetch_config(&self) -> Config
pub async fn fetch_config(&self) -> Config
Fetch the current config
Sourcepub async fn update_config(&self, config: Config) -> Result<Config>
pub async fn update_config(&self, config: Config) -> Result<Config>
Update the config
Overwrites the config in the config state and returns the updated config.
Sourcepub async fn update_selected_role(&self, role_name: RoleName) -> Result<Config>
pub async fn update_selected_role(&self, role_name: RoleName) -> Result<Config>
Update only the selected_role in the config without mutating the rest of the
configuration. Returns the up-to-date Config object.
Auto Trait Implementations§
impl Freeze for TerraphimService
impl !RefUnwindSafe for TerraphimService
impl Send for TerraphimService
impl Sync for TerraphimService
impl Unpin for TerraphimService
impl UnsafeUnpin for TerraphimService
impl !UnwindSafe for TerraphimService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more