mirror of
https://github.com/perstarkse/minne.git
synced 2026-06-12 17:24:26 +02:00
chore: clean & refactor
This commit is contained in:
@@ -39,20 +39,17 @@ pub struct LLMGraphAnalysisResult {
|
||||
pub relationships: Vec<LLMRelationship>,
|
||||
}
|
||||
|
||||
/// Converts the LLM graph analysis result into database entities and relationships.
|
||||
/// Processes embeddings sequentially for simplicity.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `source_id` - A UUID representing the source identifier.
|
||||
/// * `openai_client` - OpenAI client for LLM calls.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<(Vec<KnowledgeEntity>, Vec<KnowledgeRelationship>), ProcessingError>` - A tuple containing vectors of `KnowledgeEntity` and `KnowledgeRelationship`.
|
||||
|
||||
impl LLMGraphAnalysisResult {
|
||||
// Split the main function into smaller, focused functions
|
||||
/// Converts the LLM graph analysis result into database entities and relationships.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `source_id` - A UUID representing the source identifier.
|
||||
/// * `openai_client` - OpenAI client for LLM calls.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<(Vec<KnowledgeEntity>, Vec<KnowledgeRelationship>), ProcessingError>` - A tuple containing vectors of `KnowledgeEntity` and `KnowledgeRelationship`.
|
||||
pub async fn to_database_entities(
|
||||
&self,
|
||||
source_id: &str,
|
||||
@@ -61,7 +58,7 @@ impl LLMGraphAnalysisResult {
|
||||
// Create mapper and pre-assign IDs
|
||||
let mapper = Arc::new(Mutex::new(self.create_mapper()?));
|
||||
|
||||
// Process entities (prepared for future parallelization)
|
||||
// Process entities
|
||||
let entities = self
|
||||
.process_entities(source_id, Arc::clone(&mapper), openai_client)
|
||||
.await?;
|
||||
|
||||
@@ -37,7 +37,8 @@ impl ContentProcessor {
|
||||
store_item(&self.db_client, content.clone()).await?;
|
||||
|
||||
let now = Instant::now();
|
||||
// Process in parallel where possible
|
||||
|
||||
// Perform analyis, this step also includes retrieval
|
||||
let analysis = self.perform_semantic_analysis(content).await?;
|
||||
|
||||
let end = now.elapsed();
|
||||
@@ -46,7 +47,7 @@ impl ContentProcessor {
|
||||
end
|
||||
);
|
||||
|
||||
// Convert and store entities
|
||||
// Convert analysis to objects
|
||||
let (entities, relationships) = analysis
|
||||
.to_database_entities(&content.id, &self.openai_client)
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user