mirror of
https://github.com/jina-ai/node-DeepResearch.git
synced 2025-12-26 06:28:56 +08:00
fix: logger
This commit is contained in:
parent
76dc568e52
commit
a179807c5a
@ -267,7 +267,7 @@ async function updateReferences(thisStep: AnswerAction, allURLs: Record<string,
|
||||
ref.dateTime = await getLastModified(ref.url) || '';
|
||||
}));
|
||||
|
||||
console.log('Updated references:', thisStep.references);
|
||||
logDebug('Updated references:', { references: thisStep.references });
|
||||
}
|
||||
|
||||
async function executeSearchQueries(
|
||||
|
||||
@ -313,7 +313,7 @@ if (secret) {
|
||||
app.use((req, res, next) => {
|
||||
const authHeader = req.headers.authorization;
|
||||
if (!authHeader || !authHeader.startsWith('Bearer ') || authHeader.split(' ')[1] !== secret) {
|
||||
console.log('[chat/completions] Unauthorized request');
|
||||
logError('[chat/completions] Unauthorized request');
|
||||
res.status(401).json({ error: 'Unauthorized' });
|
||||
return;
|
||||
}
|
||||
@ -380,7 +380,7 @@ app.post('/v1/chat/completions', (async (req: Request, res: Response) => {
|
||||
if (secret) {
|
||||
const authHeader = req.headers.authorization;
|
||||
if (!authHeader || !authHeader.startsWith('Bearer ') || authHeader.split(' ')[1] !== secret) {
|
||||
console.log('[chat/completions] Unauthorized request');
|
||||
logError('[chat/completions] Unauthorized request');
|
||||
res.status(401).json({ error: 'Unauthorized' });
|
||||
return;
|
||||
}
|
||||
@ -392,7 +392,7 @@ app.post('/v1/chat/completions', (async (req: Request, res: Response) => {
|
||||
req.socket.remoteAddress ||
|
||||
'unknown';
|
||||
// Log request details (excluding sensitive data)
|
||||
console.log('[chat/completions] Request:', {
|
||||
logInfo('[chat/completions] Request:', {
|
||||
model: req.body.model,
|
||||
stream: req.body.stream,
|
||||
messageCount: req.body.messages?.length,
|
||||
@ -410,7 +410,7 @@ app.post('/v1/chat/completions', (async (req: Request, res: Response) => {
|
||||
return res.status(400).json({ error: 'Last message must be from user' });
|
||||
}
|
||||
|
||||
console.log('messages', JSON.stringify(body.messages));
|
||||
logDebug('Input messages', { messages: body.messages });
|
||||
|
||||
// clean <think> from all assistant messages
|
||||
body.messages = body.messages?.filter(message => {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import {TokenTracker} from "../utils/token-tracker";
|
||||
import {cosineSimilarity} from "./cosine";
|
||||
import {getEmbeddings} from "./embeddings";
|
||||
import { logDebug, logError, logInfo } from "../logging";
|
||||
import { TokenTracker } from "../utils/token-tracker";
|
||||
import { cosineSimilarity } from "./cosine";
|
||||
import { getEmbeddings } from "./embeddings";
|
||||
|
||||
const SIMILARITY_THRESHOLD = 0.86; // Adjustable threshold for cosine similarity
|
||||
|
||||
@ -20,7 +21,7 @@ export async function dedupQueries(
|
||||
|
||||
// Get embeddings for all queries in one batch
|
||||
const allQueries = [...newQueries, ...existingQueries];
|
||||
const {embeddings: allEmbeddings} = await getEmbeddings(allQueries, tracker);
|
||||
const { embeddings: allEmbeddings } = await getEmbeddings(allQueries, tracker);
|
||||
|
||||
// If embeddings is empty (due to 402 error), return all new queries
|
||||
if (!allEmbeddings.length) {
|
||||
@ -66,12 +67,12 @@ export async function dedupQueries(
|
||||
usedIndices.add(i);
|
||||
}
|
||||
}
|
||||
console.log('Dedup:', uniqueQueries);
|
||||
logInfo('Dedup:', { uniqueQueries });
|
||||
return {
|
||||
unique_queries: uniqueQueries,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error in deduplication analysis:', error);
|
||||
logError('Error in deduplication analysis:', { error });
|
||||
|
||||
// return all new queries if there is an error
|
||||
return {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user