Skip to content

Commit a2f1a21

Browse files
authored
Merge pull request #59 from ethernautdao/optimist
Optimist module initial functions
2 parents c24752d + 66edd02 commit a2f1a21

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1643
-43
lines changed

package-lock.json

Lines changed: 97 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
"prettier": "^3.2.5"
2626
},
2727
"dependencies": {
28-
"echomd": "^0.2.3"
28+
"axios": "^1.8.4",
29+
"echomd": "^0.2.3",
30+
"node-fetch": "^2.7.0"
2931
}
3032
}

packages/ethernaut-ai/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
**/src/internal/assistants/docs/kb-files
1+
**/src/internal/assistants/docs/kb-files/output/optimism/community-hub/chapters
2+
**/src/internal/assistants/docs/kb-files/output/optimism/docs/chapters

packages/ethernaut-ai/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ethernaut-ai",
33
"version": "1.1.11",
4-
"description": "AI assistant that interprets user input and executes hardhat tasks",
4+
"description": "AI assistant that interprets user input and executes hardhat tasks and chat with OP docs",
55
"main": "src/index.js",
66
"scripts": {
77
"build": "npm run install:test",

packages/ethernaut-ai/src/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,11 @@ extendConfig((config, userConfig) => {
4545
userConfig.ethernaut?.ai?.explainer?.additionalInstructions.concat() ||
4646
[],
4747
},
48+
docs: {
49+
additionalInstructions:
50+
localConfig.ai?.docs?.additionalInstructions?.concat() ||
51+
userConfig.ethernaut?.ai?.docs?.additionalInstructions?.concat() ||
52+
[],
53+
},
4854
}
4955
})
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const buildDocsDocs = require('./utils/build-docs-docs')
2+
const Assistant = require('./Assistant')
3+
4+
class DocsAssistant extends Assistant {
5+
constructor(hre) {
6+
const config = require('./configs/docs.json')
7+
config.tools = []
8+
super('docs', config)
9+
this.injectAdditionalInstructions(
10+
hre.config.ethernaut.ai.docs.additionalInstructions,
11+
)
12+
13+
this.hre = hre
14+
}
15+
16+
async process(thread, model) {
17+
const messages = await thread.getMessages()
18+
const lastMessage = messages.data[0]
19+
const query = lastMessage.content[0].text.value
20+
// Load and inject the OP Developer Docs based on the query
21+
const DocsDocs = await buildDocsDocs(query)
22+
this.config.instructions = this.config.instructions.replace(
23+
'[docs-docs]',
24+
DocsDocs.join('\n\n'),
25+
)
26+
27+
return await super.process(thread, model)
28+
}
29+
}
30+
31+
module.exports = DocsAssistant
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "EthernautAI OP Developer Docs",
3+
"description": "A documentation assistant that provides information from the Optimism Developer Docs",
4+
"instructions": "[common] Your role is to be a documentation assistant that answers questions about the Optimism ecosystem. You should ONLY provide direct answers based on the documentation provided, without suggesting or executing any commands. When answering: 1. Use the documentation content to provide accurate information 2. Cite specific sections or documents when providing information 3. If a question cannot be answered with the available documentation, clearly state that 4. Do not suggest or try to execute any CLI commands 5. Format your responses in a clear, readable way 6. If relevant, you can provide direct quotes from the documentation [docs-docs] [additional]",
5+
"model": "gpt-4o-mini"
6+
}

packages/ethernaut-ai/src/internal/assistants/docs/kb-files/output/keywords.json renamed to packages/ethernaut-ai/src/internal/assistants/docs/kb-files/last-update-docs.json

File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

packages/ethernaut-ai/src/internal/assistants/docs/kb-files/last-update.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)