Formatting

This commit is contained in:
2026-04-19 15:35:10 +02:00
parent 041f9015ca
commit 0d5c2f5888
42 changed files with 612 additions and 357 deletions
+15 -4
View File
@@ -84,7 +84,10 @@ pub async fn chat_once(
user_content: &str,
timeout: Duration,
) -> Result<String, LlmError> {
let url = format!("{}/v1/chat/completions", settings.base_url.trim_end_matches('/'));
let url = format!(
"{}/v1/chat/completions",
settings.base_url.trim_end_matches('/')
);
debug!(%url, model = settings.model, "calling llm chat completions");
let body = ChatRequest {
@@ -92,8 +95,14 @@ pub async fn chat_once(
temperature: settings.temperature,
stream: false,
messages: vec![
Message { role: "system", content: system_prompt },
Message { role: "user", content: user_content },
Message {
role: "system",
content: system_prompt,
},
Message {
role: "user",
content: user_content,
},
],
};
@@ -107,7 +116,9 @@ pub async fn chat_once(
if !status.is_success() {
// Body deliberately dropped — see LlmError docstring.
drop(response);
return Err(LlmError::Status { status: status.as_u16() });
return Err(LlmError::Status {
status: status.as_u16(),
});
}
let parsed: ChatResponse = response.json().await.map_err(LlmError::Http)?;
+1 -1
View File
@@ -2,7 +2,7 @@ use std::path::Path;
use tracing::{info, warn};
use super::{AnalyzeJob, AnalyzeSender, ANALYSIS_INPUT_FILE, DOCUMENT_FILE};
use super::{ANALYSIS_INPUT_FILE, AnalyzeJob, AnalyzeSender, DOCUMENT_FILE};
/// Walk `data_path/*/` and enqueue every pending analysis for every user.
/// Intended to run once at startup; the same primitive backs the per-user
+1 -1
View File
@@ -10,7 +10,7 @@
//! Pipeline:
//! raw markdown → html-escape → ==X== → <mark>X</mark> → pulldown-cmark → html
use pulldown_cmark::{html, Options, Parser};
use pulldown_cmark::{Options, Parser, html};
/// Render analysis Markdown to HTML. Safe to inject into an Askama template
/// with `{{ var|safe }}` because every `<`/`>` from the LLM is pre-escaped
+6 -6
View File
@@ -5,7 +5,7 @@ use std::time::Duration;
use tokio::io::AsyncWriteExt;
use tracing::{error, info, warn};
use super::{llm, prompt, AnalysisInput, AnalyzeReceiver, ANALYSIS_INPUT_FILE, DOCUMENT_FILE};
use super::{ANALYSIS_INPUT_FILE, AnalysisInput, AnalyzeReceiver, DOCUMENT_FILE, llm, prompt};
use crate::config::Config;
use crate::gazetteer::Gazetteer;
use crate::{BusyGuard, WorkerBusy};
@@ -20,10 +20,7 @@ pub async fn run(
worker_busy: WorkerBusy,
vocab: Arc<Gazetteer>,
) {
info!(
vocab_entries = vocab.len(),
"Analyze worker started"
);
info!(vocab_entries = vocab.len(), "Analyze worker started");
let timeout = Duration::from_secs(config.llm_timeout_seconds);
while let Some(job) = rx.recv().await {
@@ -144,7 +141,10 @@ async fn process(
/// state machine simply sees the job as still pending and retries.
async fn write_atomic(path: &Path, bytes: &[u8]) -> std::io::Result<()> {
let tmp = path.with_extension({
let mut ext = path.extension().map(|s| s.to_os_string()).unwrap_or_default();
let mut ext = path
.extension()
.map(|s| s.to_os_string())
.unwrap_or_default();
ext.push(".tmp");
ext
});