-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into onboarding/util-timestamp
- Loading branch information
Showing
5 changed files
with
74 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ethernaut-ai-ui/test/tasks/config.test.js → .../ethernaut-ai-ui/test/tasks/model.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const types = require('ethernaut-common/src/validation/types') | ||
const output = require('ethernaut-common/src/ui/output') | ||
const storage = require('ethernaut-common/src/io/storage') | ||
const { setEnvVar } = require('ethernaut-common/src/io/env') | ||
|
||
require('../scopes/ai') | ||
.task('key', 'Sets the openai api key') | ||
.addParam('apiKey', 'The openai api key to use', undefined, types.string) | ||
.setAction(async ({ apiKey }, hre) => { | ||
try { | ||
const config = storage.readConfig() | ||
|
||
let summary = [] | ||
|
||
if (apiKey) { | ||
const currentKey = process.env.OPENAI_API_KEY | ||
setEnvVar('OPENAI_API_KEY', apiKey) | ||
summary.push(`- API Key set to ${apiKey} (was ${currentKey})`) | ||
} | ||
|
||
storage.saveConfig(config) | ||
|
||
if (summary.length === 0) { | ||
summary.push('No changes') | ||
} | ||
|
||
return output.resultBox(summary.join('\n')) | ||
} catch (err) { | ||
return output.errorBox(err) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters