Skip to content

Commit

Permalink
fix: linter
Browse files Browse the repository at this point in the history
Signed-off-by: sarthakjdev <[email protected]>
  • Loading branch information
sarthakjdev committed Jul 20, 2024
1 parent ea0aaf7 commit 1ac7640
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
1 change: 0 additions & 1 deletion apps/wapi-ai-chatbot/src/index.ts
Original file line number Diff line number Diff line change
@@ -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() {

Check warning on line 5 in apps/wapi-ai-chatbot/src/index.ts

View workflow job for this annotation

GitHub Actions / build-and-lint

Async function 'init' has no 'await' expression
try {
Expand Down
22 changes: 11 additions & 11 deletions apps/wapi-ai-chatbot/src/utils/cache.ts
Original file line number Diff line number Diff line change
@@ -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 }) {

Check warning on line 7 in apps/wapi-ai-chatbot/src/utils/cache.ts

View workflow job for this annotation

GitHub Actions / build-and-lint

Unexpected any. Specify a different type
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<T>(key: string): Promise<T> {
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'
})
}
2 changes: 1 addition & 1 deletion apps/wapi-ai-chatbot/src/utils/gpt.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 1ac7640

Please sign in to comment.