Skip to content

Commit

Permalink
Iterate
Browse files Browse the repository at this point in the history
  • Loading branch information
serefyarar committed May 14, 2024
1 parent 1bdc77a commit 301ef84
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
23 changes: 11 additions & 12 deletions api/src/libs/kafka-indexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ export const updateIndexItemEvent = async (id) => {
}
}


async function updateQuestions(indexItem) {
try {
let response = await axios.get(`${process.env.LLM_INDEXER_HOST}/chat/generate?indexId=${indexItem.index.id}`);
await redis.set(`questions:${indexItem.index.id}`, JSON.stringify(response.data), 'EX', 86400);
} catch (error) {
console.error('Error fetching or caching data:', error);
}
}

export const updateWebPageEvent = async (id) => {

logger.info(`Step [2]: UpdateWebPageEvent trigger for id: ${id}`)
Expand Down Expand Up @@ -139,20 +149,9 @@ export const updateWebPageEvent = async (id) => {
});


updateQuestions(indexItem)
logger.info(`Step [2]: EmbeddingEvent trigger successfull for id: ${embedding.id}`);

// Cache updated questions to reddis
try {

let response = await axios.get(`${process.env.LLM_INDEXER_HOST}/chat/generate?indexId=${indexItem.index.id}`)
redis.set(`questions:${indexItem.index.id}`, JSON.stringify(response.data), { EX: 86400 } );

logger.info(`Step [2]: Questions for index ${indexItem.index.id} updated in redis with ${JSON.stringify(response.data)} questions`)

} catch (error) {
logger.warn(`Step [2]: Questions for index ${indexItem.index.id} not updated in redis with error: ${JSON.stringify(error.message)}`)
}

}
}

Expand Down
14 changes: 7 additions & 7 deletions sdk/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@indexnetwork/sdk",
"version": "0.0.11",
"version": "0.0.12",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -9,22 +9,22 @@
"watch": "tsc --watch"
},
"devDependencies": {
"@types/node": "^20.11.27",
"@types/node": "^20.12.11",
"prettier": "^3.2.5",
"tslib": "^2.6.2",
"typescript": "^4.7.2"
},
"dependencies": {
"@didtools/cacao": "^3.0.1",
"@langchain/community": "^0.0.53",
"did-session": "^3.1.0",
"multiformats": "^13.1.0",
"@langchain/openai": "^0.0.28",
"ethers": "^6.12.0",
"uuid": "^9.0.1",
"chromadb": "^1.8.1",
"did-session": "^3.1.0",
"ethers": "^6.12.0",
"langchain": "^0.1.36",
"openai": "^4.38.5"
"multiformats": "^13.1.0",
"openai": "^4.38.5",
"uuid": "^9.0.1"
},
"exports": "./dist/index.js"
}
8 changes: 4 additions & 4 deletions sdk/js/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,10 @@
dependencies:
undici-types "~5.26.4"

"@types/node@^20.11.27":
version "20.11.28"
resolved "https://registry.npmjs.org/@types/node/-/node-20.11.28.tgz"
integrity sha512-M/GPWVS2wLkSkNHVeLkrF2fD5Lx5UC4PxA0uZcKc6QqbIQUJyW1jVjueJYi1z8n0I5PxYrtpnPnWglE+y9A0KA==
"@types/node@^20.12.11":
version "20.12.11"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.12.11.tgz#c4ef00d3507000d17690643278a60dc55a9dc9be"
integrity sha512-vDg9PZ/zi+Nqp6boSOT7plNuthRugEKixDv5sFTIpkE89MmNtEArAShI4mxuX2+UrLEe9pxC1vm2cjm9YlWbJw==
dependencies:
undici-types "~5.26.4"

Expand Down

0 comments on commit 301ef84

Please sign in to comment.