refactor: update logging imports and enhance error messages

This commit is contained in:
Han Xiao 2025-06-10 19:48:27 -07:00
parent a59a524d1c
commit 147aa4befd
4 changed files with 7 additions and 5 deletions

View File

@ -5,7 +5,7 @@ import { cosineSimilarity, jaccardRank } from "./cosine";
import { getEmbeddings } from "./embeddings";
import { dedupImagesWithEmbeddings } from '../utils/image-tools';
import { normalizeHostName } from '../utils/url-tools';
import { logInfo, logError, logDebug, logWarning } from '../logging';
import { logError, logDebug } from '../logging';
export async function buildReferences(
answer: string,

View File

@ -3,7 +3,7 @@ import { getKnowledgeStr } from "../utils/text-tools";
import { getModel } from "../config";
import { generateText } from "ai";
import { Schemas } from "../utils/schemas";
import { logInfo, logError, logDebug } from '../logging';
import { logInfo, logError, logDebug, logWarning } from '../logging';
function getPrompt(mdContent: string, allKnowledge: KnowledgeItem[], schema: Schemas): PromptPair {
@ -86,7 +86,10 @@ export async function reviseAnswer(
logDebug(`repaired before/after: ${mdContent.length} -> ${result.text.length}`);
if (result.text.length < mdContent.length * 0.85) {
logError(`repaired content length ${result.text.length} is significantly shorter than original content ${mdContent.length}, return original content instead.`);
logWarning(`repaired content length ${result.text.length} is significantly shorter than original content ${mdContent.length}, return original content instead.`, {
originalContent: mdContent,
repairedContent: result.text
});
return mdContent;
}

View File

@ -56,7 +56,6 @@ axiosClient.interceptors.response.use(
(response) => response,
(error) => {
if (error.code === 'ECONNABORTED') {
logError('Request timed out:', { error: error.message });
error.request?.destroy?.();
}
if (axios.isAxiosError(error)) {

View File

@ -430,7 +430,7 @@ export async function getLastModified(url: string): Promise<string | undefined>
return undefined;
} catch (error) {
logError('Failed to fetch last modified date:');
logError('Failed to fetch last modified date', { error });
return undefined;
}
}