mirror of
https://github.com/perstarkse/minne.git
synced 2026-04-24 01:38:29 +02:00
refactor: renamed instructions to context
This commit is contained in:
@@ -40,17 +40,17 @@ impl IngestionEnricher {
|
||||
pub async fn analyze_content(
|
||||
&self,
|
||||
category: &str,
|
||||
instructions: &str,
|
||||
context: Option<&str>,
|
||||
text: &str,
|
||||
user_id: &str,
|
||||
) -> Result<LLMEnrichmentResult, AppError> {
|
||||
info!("getting similar entitities");
|
||||
let similar_entities = self
|
||||
.find_similar_entities(category, instructions, text, user_id)
|
||||
.find_similar_entities(category, context, text, user_id)
|
||||
.await?;
|
||||
info!("got similar entitities");
|
||||
let llm_request = self
|
||||
.prepare_llm_request(category, instructions, text, &similar_entities)
|
||||
.prepare_llm_request(category, context, text, &similar_entities)
|
||||
.await?;
|
||||
self.perform_analysis(llm_request).await
|
||||
}
|
||||
@@ -58,13 +58,13 @@ impl IngestionEnricher {
|
||||
async fn find_similar_entities(
|
||||
&self,
|
||||
category: &str,
|
||||
instructions: &str,
|
||||
context: Option<&str>,
|
||||
text: &str,
|
||||
user_id: &str,
|
||||
) -> Result<Vec<KnowledgeEntity>, AppError> {
|
||||
let input_text = format!(
|
||||
"content: {}, category: {}, user_instructions: {}",
|
||||
text, category, instructions
|
||||
"content: {}, category: {}, user_context: {:?}",
|
||||
text, category, context
|
||||
);
|
||||
|
||||
retrieve_entities(&self.db_client, &self.openai_client, &input_text, user_id).await
|
||||
@@ -73,7 +73,7 @@ impl IngestionEnricher {
|
||||
async fn prepare_llm_request(
|
||||
&self,
|
||||
category: &str,
|
||||
instructions: &str,
|
||||
context: Option<&str>,
|
||||
text: &str,
|
||||
similar_entities: &[KnowledgeEntity],
|
||||
) -> Result<CreateChatCompletionRequest, AppError> {
|
||||
@@ -93,8 +93,8 @@ impl IngestionEnricher {
|
||||
.collect::<Vec<_>>());
|
||||
|
||||
let user_message = format!(
|
||||
"Category:\n{}\nInstructions:\n{}\nContent:\n{}\nExisting KnowledgeEntities in database:\n{}",
|
||||
category, instructions, text, entities_json
|
||||
"Category:\n{}\ncontext:\n{:?}\nContent:\n{}\nExisting KnowledgeEntities in database:\n{}",
|
||||
category, context, text, entities_json
|
||||
);
|
||||
|
||||
debug!("Prepared LLM request message: {}", user_message);
|
||||
|
||||
@@ -113,7 +113,7 @@ impl IngestionPipeline {
|
||||
analyser
|
||||
.analyze_content(
|
||||
&content.category,
|
||||
&content.instructions,
|
||||
content.context.as_deref(),
|
||||
&content.text,
|
||||
&content.user_id,
|
||||
)
|
||||
|
||||
@@ -16,7 +16,7 @@ use common::{
|
||||
},
|
||||
};
|
||||
use dom_smoothie::{Article, Readability, TextMode};
|
||||
use headless_chrome::{Browser, LaunchOptionsBuilder};
|
||||
use headless_chrome::Browser;
|
||||
use std::io::{Seek, SeekFrom};
|
||||
use tempfile::NamedTempFile;
|
||||
use tracing::{error, info};
|
||||
@@ -28,14 +28,14 @@ pub async fn to_text_content(
|
||||
match ingestion_payload {
|
||||
IngestionPayload::Url {
|
||||
url,
|
||||
instructions,
|
||||
context,
|
||||
category,
|
||||
user_id,
|
||||
} => {
|
||||
let (article, file_info) = fetch_article_from_url(&url, db, &user_id).await?;
|
||||
Ok(TextContent::new(
|
||||
article.text_content.into(),
|
||||
instructions,
|
||||
Some(context),
|
||||
category,
|
||||
None,
|
||||
Some(UrlInfo {
|
||||
@@ -48,12 +48,12 @@ pub async fn to_text_content(
|
||||
}
|
||||
IngestionPayload::Text {
|
||||
text,
|
||||
instructions,
|
||||
context,
|
||||
category,
|
||||
user_id,
|
||||
} => Ok(TextContent::new(
|
||||
text,
|
||||
instructions,
|
||||
Some(context),
|
||||
category,
|
||||
None,
|
||||
None,
|
||||
@@ -61,14 +61,14 @@ pub async fn to_text_content(
|
||||
)),
|
||||
IngestionPayload::File {
|
||||
file_info,
|
||||
instructions,
|
||||
context,
|
||||
category,
|
||||
user_id,
|
||||
} => {
|
||||
let text = extract_text_from_file(&file_info).await?;
|
||||
Ok(TextContent::new(
|
||||
text,
|
||||
instructions,
|
||||
Some(context),
|
||||
category,
|
||||
Some(file_info),
|
||||
None,
|
||||
|
||||
Reference in New Issue
Block a user