mirror of
https://github.com/jina-ai/node-DeepResearch.git
synced 2026-03-22 07:29:35 +08:00
refactor: update logging imports and enhance error messages
This commit is contained in:
@@ -5,7 +5,7 @@ import { cosineSimilarity, jaccardRank } from "./cosine";
|
|||||||
import { getEmbeddings } from "./embeddings";
|
import { getEmbeddings } from "./embeddings";
|
||||||
import { dedupImagesWithEmbeddings } from '../utils/image-tools';
|
import { dedupImagesWithEmbeddings } from '../utils/image-tools';
|
||||||
import { normalizeHostName } from '../utils/url-tools';
|
import { normalizeHostName } from '../utils/url-tools';
|
||||||
import { logInfo, logError, logDebug, logWarning } from '../logging';
|
import { logError, logDebug } from '../logging';
|
||||||
|
|
||||||
export async function buildReferences(
|
export async function buildReferences(
|
||||||
answer: string,
|
answer: string,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { getKnowledgeStr } from "../utils/text-tools";
|
|||||||
import { getModel } from "../config";
|
import { getModel } from "../config";
|
||||||
import { generateText } from "ai";
|
import { generateText } from "ai";
|
||||||
import { Schemas } from "../utils/schemas";
|
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 {
|
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}`);
|
logDebug(`repaired before/after: ${mdContent.length} -> ${result.text.length}`);
|
||||||
|
|
||||||
if (result.text.length < mdContent.length * 0.85) {
|
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;
|
return mdContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ axiosClient.interceptors.response.use(
|
|||||||
(response) => response,
|
(response) => response,
|
||||||
(error) => {
|
(error) => {
|
||||||
if (error.code === 'ECONNABORTED') {
|
if (error.code === 'ECONNABORTED') {
|
||||||
logError('Request timed out:', { error: error.message });
|
|
||||||
error.request?.destroy?.();
|
error.request?.destroy?.();
|
||||||
}
|
}
|
||||||
if (axios.isAxiosError(error)) {
|
if (axios.isAxiosError(error)) {
|
||||||
|
|||||||
@@ -430,7 +430,7 @@ export async function getLastModified(url: string): Promise<string | undefined>
|
|||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logError('Failed to fetch last modified date:');
|
logError('Failed to fetch last modified date', { error });
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user