fix(telegram-bot): context window issue

This commit is contained in:
Neko Ayaka
2025-03-30 22:37:41 +08:00
parent 8e2aa91e93
commit a278937a53
2 changed files with 2 additions and 2 deletions
@@ -26,7 +26,7 @@ export async function readMessage(
}> {
const logger = useLogg('readMessage').useGlobalConfig()
const lastNMessages = await findLastNMessages(action.chatId, 10)
const lastNMessages = await findLastNMessages(action.chatId, 100)
const lastNMessagesOneliner = lastNMessages.map(msg => chatMessageToOneLine(botId, msg)).join('\n')
logger.withField('number_of_last_n_messages', lastNMessages.length).log('Successfully found last N messages')
@@ -85,7 +85,7 @@ export async function findLastNMessages(chatId: string, n: number) {
export async function findRelevantMessages(botId: string, chatId: string, unreadHistoryMessagesEmbedding: { embedding: number[] }[], excludeMessageIds: string[] = []) {
const db = useDrizzle()
const contextWindowSize = 2 // Number of messages to include before and after
const contextWindowSize = 10 // Number of messages to include before and after
const logger = useLogg('findRelevantMessages').useGlobalConfig().withField('chatId', chatId)
logger.withField('context_window_size', contextWindowSize).log('Querying relevant chat messages...')