Skip to content

Commit

Permalink
feat: add brain refresh command
Browse files Browse the repository at this point in the history
  • Loading branch information
snowyu committed Aug 10, 2024
1 parent adcc9c9 commit 88590c7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/oclif/commands/brain/refresh.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { upgradeBrains } from '../../../lib/brain.js'
import { AICommand } from '../../lib/ai-command.js'
import { showBanner } from '../../lib/help.js'

export default class AIBrainRefreshCommand extends AICommand {
static summary = '🔄 refresh online brains.'

static description = 'refresh brain index from huggingface.co'
async run(): Promise<any> {
const opts = await this.parse(AIBrainRefreshCommand)
const isJson = this.jsonEnabled()
const {flags} = opts
const userConfig = this.loadConfig(flags.config, opts)
await this.config.runHook('init_tools', {id: 'brain', userConfig})

if (userConfig.banner && !isJson) {showBanner('Refresh Brains')}

const count = await upgradeBrains(flags)
this.log(`${count} brains updated`)

return count
}
}

0 comments on commit 88590c7

Please sign in to comment.