feat(logging): add logger

This commit is contained in:
ItzCrazyKns
2024-04-30 12:18:18 +05:30
parent 7c84025f3c
commit aae85cd767
15 changed files with 240 additions and 17 deletions

View File

@@ -18,6 +18,7 @@ import type { Embeddings } from '@langchain/core/embeddings';
import formatChatHistoryAsString from '../utils/formatHistory';
import eventEmitter from 'events';
import computeSimilarity from '../utils/computeSimilarity';
import logger from '../utils/logger';
const basicAcademicSearchRetrieverPrompt = `
You will be given a conversation below and a follow up question. You need to rephrase the follow-up question if needed so it is a standalone question that can be used by the LLM to search the web for information.
@@ -245,7 +246,7 @@ const basicAcademicSearch = (
'error',
JSON.stringify({ data: 'An error has occurred please try again later' }),
);
console.error(err);
logger.error(`Error in academic search: ${err}`);
}
return emitter;

View File

@@ -18,6 +18,7 @@ import type { Embeddings } from '@langchain/core/embeddings';
import formatChatHistoryAsString from '../utils/formatHistory';
import eventEmitter from 'events';
import computeSimilarity from '../utils/computeSimilarity';
import logger from '../utils/logger';
const basicRedditSearchRetrieverPrompt = `
You will be given a conversation below and a follow up question. You need to rephrase the follow-up question if needed so it is a standalone question that can be used by the LLM to search the web for information.
@@ -240,7 +241,7 @@ const basicRedditSearch = (
'error',
JSON.stringify({ data: 'An error has occurred please try again later' }),
);
console.error(err);
logger.error(`Error in RedditSearch: ${err}`);
}
return emitter;

View File

@@ -18,6 +18,7 @@ import type { Embeddings } from '@langchain/core/embeddings';
import formatChatHistoryAsString from '../utils/formatHistory';
import eventEmitter from 'events';
import computeSimilarity from '../utils/computeSimilarity';
import logger from '../utils/logger';
const basicSearchRetrieverPrompt = `
You will be given a conversation below and a follow up question. You need to rephrase the follow-up question if needed so it is a standalone question that can be used by the LLM to search the web for information.
@@ -241,7 +242,7 @@ const basicWebSearch = (
'error',
JSON.stringify({ data: 'An error has occurred please try again later' }),
);
console.error(err);
logger.error(`Error in websearch: ${err}`);
}
return emitter;

View File

@@ -17,6 +17,7 @@ import type { BaseChatModel } from '@langchain/core/language_models/chat_models'
import type { Embeddings } from '@langchain/core/embeddings';
import formatChatHistoryAsString from '../utils/formatHistory';
import eventEmitter from 'events';
import logger from '../utils/logger';
const basicWolframAlphaSearchRetrieverPrompt = `
You will be given a conversation below and a follow up question. You need to rephrase the follow-up question if needed so it is a standalone question that can be used by the LLM to search the web for information.
@@ -199,7 +200,7 @@ const basicWolframAlphaSearch = (
'error',
JSON.stringify({ data: 'An error has occurred please try again later' }),
);
console.error(err);
logger.error(`Error in WolframAlphaSearch: ${err}`);
}
return emitter;

View File

@@ -9,6 +9,7 @@ import type { StreamEvent } from '@langchain/core/tracers/log_stream';
import eventEmitter from 'events';
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
import type { Embeddings } from '@langchain/core/embeddings';
import logger from '../utils/logger';
const writingAssistantPrompt = `
You are Perplexica, an AI model who is expert at searching the web and answering user's queries. You are currently set on focus mode 'Writing Assistant', this means you will be helping the user write a response to a given query.
@@ -80,7 +81,7 @@ const handleWritingAssistant = (
'error',
JSON.stringify({ data: 'An error has occurred please try again later' }),
);
console.error(err);
logger.error(`Error in writing assistant: ${err}`);
}
return emitter;

View File

@@ -18,6 +18,7 @@ import type { Embeddings } from '@langchain/core/embeddings';
import formatChatHistoryAsString from '../utils/formatHistory';
import eventEmitter from 'events';
import computeSimilarity from '../utils/computeSimilarity';
import logger from '../utils/logger';
const basicYoutubeSearchRetrieverPrompt = `
You will be given a conversation below and a follow up question. You need to rephrase the follow-up question if needed so it is a standalone question that can be used by the LLM to search the web for information.
@@ -241,7 +242,7 @@ const basicYoutubeSearch = (
'error',
JSON.stringify({ data: 'An error has occurred please try again later' }),
);
console.error(err);
logger.error(`Error in youtube search: ${err}`);
}
return emitter;