Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
**/coverage
.nyc_output
.nyc_cache
.DS_Store
.DS_Store


packages/ethernaut-ai/src/internal/assistants/docs/kb-files/

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ethernaut-cli-monorepo",
"version": "1.1.12",
"version": "1.2.0",
"private": true,
"workspaces": [
"packages/*"
Expand Down
2 changes: 0 additions & 2 deletions packages/ethernaut-ai/.gitignore

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ const path = require('path')
const openai = require('../../openai')
const VECTOR_STORE_ID = 'OP_DOCS_7'

const documentKeywords = require('../docs/kb-files/output/optimism/docs/keywords.json')
let documentKeywords = {}
try {
documentKeywords = require('../docs/kb-files/output/optimism/docs/keywords.json')
} catch (err) {
// expected exception on 1st run
if (err.code !== 'MODULE_NOT_FOUND') {
throw err
}
}

// New vector store implementation 🔴
async function buildDocsDocsWithVector(query) {
Expand All @@ -30,7 +38,10 @@ async function buildDocsDocsWithVector(query) {
__dirname,
'../docs/kb-files/output/optimism/docs/chapters',
)
const files = Object.keys(documentKeywords)
const files =
Object.keys(documentKeywords).length > 0
? Object.keys(documentKeywords)
: fs.readdirSync(docsDir).filter((file) => file.endsWith('.md'))
const batchSize = 5 // Upload files in batches to avoid rate limits
const allFileIds = []

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ function calculateRelevance(query, keywords) {
// Original keyword-based implementation
// DEPRECATED
// Keywords associated with each document
const documentKeywords = require('../docs/kb-files/output/optimism/community-hub/keywords.json')
let documentKeywords = {}
try {
documentKeywords = require('../docs/kb-files/output/optimism/community-hub/keywords.json')
} catch (err) {
// expected exception on 1st run
if (err.code !== 'MODULE_NOT_FOUND') {
throw err
}
}

function buildHubDocsWithKeywords(query) {
const docs = []
Expand All @@ -54,6 +62,11 @@ function buildHubDocsWithKeywords(query) {
'../docs/kb-files/output/optimism/community-hub/chapters',
)

// Si no hay keywords, devolver array vacío
if (Object.keys(documentKeywords).length === 0) {
return docs
}

// Calculate relevance for each document
const relevanceScores = Object.entries(documentKeywords).map(
([file, keywords]) => ({
Expand Down Expand Up @@ -100,10 +113,13 @@ async function buildHubDocsWithVector(query) {

const docsDir = path.join(
__dirname,
'../docs/kb-files/output/optimism/docs/chapters',
'../docs/kb-files/output/optimism/community-hub/chapters',
)

const files = Object.keys(documentKeywords)
const files =
Object.keys(documentKeywords).length > 0
? Object.keys(documentKeywords)
: fs.readdirSync(docsDir).filter((file) => file.endsWith('.md'))
const batchSize = 5 // Upload files in batches to avoid rate limits
const allFileIds = []

Expand Down
2 changes: 1 addition & 1 deletion packages/ethernaut-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ethernaut-cli",
"version": "1.2.0",
"version": "1.1.12",
"description": "Ai agent cli with web3 capabilities",
"license": "ISC",
"author": "Alejandro Santander",
Expand Down