Skip to content

Commit

Permalink
fix: error handling and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Björn Urban committed Oct 22, 2024
1 parent 2563c0c commit 4f92be2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,20 @@ async fn process_documents_batch(documents: &Vec<Document>, ollama: &Ollama, mod
Mode::NoAnalyze => (),
_ =>
if let Some(err) = extract_default_fields(ollama, &model, &prompt_base, client, &default_fields, base_url, &document, tag_mode, PaperlessDefaultFieldType::Tag).await {
return Err(err);
slog_scope::error!("Error while getting tags: {:?}", err);
}
}
match doctype_mode {
Mode::NoAnalyze => (),
_ =>
if let Some(err) = extract_default_fields(ollama, &model, &prompt_base, client, &default_fields, base_url, &document, doctype_mode, PaperlessDefaultFieldType::DocumentType).await {
return Err(err);
slog_scope::error!("Error while getting doctype: {:?}", err);
}
}
match correspondent_mode {
Mode::NoAnalyze => (),
_ => if let Some(err) = extract_default_fields(ollama, &model, &prompt_base, client, &default_fields, base_url, &document, correspondent_mode, PaperlessDefaultFieldType::Correspondent).await {
return Err(err);
slog_scope::error!("Error while getting correspondents: {:?}", err);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/paperless_defaultfields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{extract_json_object, Document, Field, Mode};
use crate::llm_api::generate_response;
use crate::paperless::{get_default_fields, update_document_default_fields, update_document_fields, DefaultField, PaperlessDefaultFieldType};

const ANSWER_INSTRUCTION: &'static str = "The result should be a only a json array of string and nothing else. The answer should start and end with the square bracket. The document is: ";
const ANSWER_INSTRUCTION: &'static str = "The result should be a only a non-nested one dimensional json array of correctly quoted strings and nothing else. The answer should start and end with the square bracket. The document is: ";
async fn construct_document_type_prompt(client: &Client, base_url: &str) -> Result<String, Box<dyn StdError + Send + Sync>> {
let document_types = get_default_fields(client, base_url, PaperlessDefaultFieldType::DocumentType).await;
let base_prompt = format!("Determine the type of this document from the following available document types: {:?}, if none of these fit the document, create a new one. ", document_types);
Expand Down

0 comments on commit 4f92be2

Please sign in to comment.