From 1ac7640bd915bdc35769e97069901291baa2f890 Mon Sep 17 00:00:00 2001 From: sarthakjdev Date: Sat, 20 Jul 2024 10:59:21 +0530 Subject: [PATCH] fix: linter Signed-off-by: sarthakjdev --- apps/wapi-ai-chatbot/src/index.ts | 1 - apps/wapi-ai-chatbot/src/utils/cache.ts | 22 +++++++++++----------- apps/wapi-ai-chatbot/src/utils/gpt.ts | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/apps/wapi-ai-chatbot/src/index.ts b/apps/wapi-ai-chatbot/src/index.ts index 24e83fb..a3c7f98 100644 --- a/apps/wapi-ai-chatbot/src/index.ts +++ b/apps/wapi-ai-chatbot/src/index.ts @@ -1,7 +1,6 @@ import { TextMessage, type TextMessageEvent } from '@wapijs/wapi.js' import { whatsappClient } from './utils/client' import { askAi } from './utils/gpt' -import { cacheData, computeCacheKey, getCachedData } from './utils/cache' async function init() { try { diff --git a/apps/wapi-ai-chatbot/src/utils/cache.ts b/apps/wapi-ai-chatbot/src/utils/cache.ts index 3985e97..1f0d1e3 100644 --- a/apps/wapi-ai-chatbot/src/utils/cache.ts +++ b/apps/wapi-ai-chatbot/src/utils/cache.ts @@ -1,27 +1,27 @@ import { caching } from 'cache-manager' const cacheStore = caching({ - store: 'memory' + store: 'memory' }) export async function cacheData(params: { key: string; data: any; ttl?: number }) { - const { key, ttl, data } = params - await cacheStore.set(key, data, { ...(ttl ? { ttl: ttl } : {}) }) + const { key, ttl, data } = params + await cacheStore.set(key, data, { ...(ttl ? { ttl: ttl } : {}) }) } export async function getCachedData(key: string): Promise { - const response = await cacheStore.get(key) - console.log(response) - return response as T + const response = await cacheStore.get(key) + console.log(response) + return response as T } export function computeCacheKey(params: { id: string; context: string }) { - return `${params.id}-${params.context}` + return `${params.id}-${params.context}` } export function getConversationContextCacheKey(phoneNumber: string) { - return computeCacheKey({ - id: phoneNumber, - context: 'conversation' - }) + return computeCacheKey({ + id: phoneNumber, + context: 'conversation' + }) } diff --git a/apps/wapi-ai-chatbot/src/utils/gpt.ts b/apps/wapi-ai-chatbot/src/utils/gpt.ts index 9092261..4ef088e 100644 --- a/apps/wapi-ai-chatbot/src/utils/gpt.ts +++ b/apps/wapi-ai-chatbot/src/utils/gpt.ts @@ -1,6 +1,6 @@ import { OpenAI } from 'openai' import { cacheData, computeCacheKey, getCachedData, getConversationContextCacheKey } from './cache' -import { AiConversationRoleEnum, ConversationMessageType } from '~/types' +import { AiConversationRoleEnum, type ConversationMessageType } from '~/types' const openAiApiKey = process.env.OPEN_AI_API_KEY const organizationId = process.env.OPEN_AI_ORG_ID