diff options
| author | navewindre <boneyaard@gmail.com> | 2024-09-30 17:40:15 +0200 |
|---|---|---|
| committer | navewindre <boneyaard@gmail.com> | 2024-09-30 17:40:15 +0200 |
| commit | 5488c375f8e545158029e32085cb5f62dfe48819 (patch) | |
| tree | 394d5f4c2eb70dd05d2dafc8ae766f92240b8ed4 | |
| parent | b73fc066ba163c3f04fc7e225464e958ca9c05a8 (diff) | |
add tabby runner
| -rw-r--r-- | README.md | 7 | ||||
| -rwxr-xr-x | tabby-runner/index.js | 62 | ||||
| -rwxr-xr-x | tabby-runner/package.json | 6 | ||||
| -rwxr-xr-x | tabby-runner/run-client.sh | 1 | ||||
| -rwxr-xr-x | tabby-runner/run.sh | 3 |
5 files changed, 79 insertions, 0 deletions
@@ -54,6 +54,13 @@ https://tabby.tabbyml.com/docs/quick-start/register-account/ 3. copy your api key into ~/.tabby_client/agent/config.toml 4. enjoy +## for tabby autorunner + +1. put contents of tabby-runner/ into the same folder as tabby +2. edit run-client.sh to use models of your liking. consult https://tabby.tabbyml.com/docs/models +3. install node modules +4. run the script with ./run.sh. it will open tabby automatically when vim is opened. + ## for local llm (avante) 1. install ollama diff --git a/tabby-runner/index.js b/tabby-runner/index.js new file mode 100755 index 0000000..93eb768 --- /dev/null +++ b/tabby-runner/index.js @@ -0,0 +1,62 @@ +const cp = require('child_process'); +const exec = cp.exec; +let child; + +let killTabby = () => { + exec( "ps aux | grep -E 'tabby'", ( error, stdout, stderr ) => { + if( stdout ) { + console.log( stdout ); + let lines = stdout.split( '\n' ); + for( let line of lines ) { + let parts = line.split( /\s+/ ); + if( ( parts[10] === './tabby' || parts[10] == 'tabby' ) && parts[11] == 'serve' ) { + cp.spawnSync( 'pkill', ['-P', parts[1]], { stdio: 'inherit' } ); + cp.spawnSync( 'kill', [parts[1]], { stdio: 'inherit' } ); + break; + } + } + } + } ); +} + + +let loop = () => { + exec( "ps aux | grep -E 'vim|nvim'", ( error, stdout, stderr ) => { + if( stdout ) { + console.log( stdout ); + let lines = stdout.split( '\n' ); + let vimOpen = false; + for( let line of lines ) { + let parts = line.split( /\s+/ ); + if( parts[10] === 'vim' || parts[10] === 'nvim' ) { + vimOpen = true; + break; + } + } + if( vimOpen ) { + if( child ) return setTimeout( loop, 120000 ); + child = cp.exec( `./run-client.sh` ); + return setTimeout( loop, 5000 ); + } + + if( child ) { + killTabby(); + child.kill(); + } + + child = null; + setTimeout( loop, 5000 ); + } else { + if( child ) { + killTabby(); + child.kill(); + child = null; + } + + setTimeout( loop, 5000 ); + } + }); + +}; + +loop(); diff --git a/tabby-runner/package.json b/tabby-runner/package.json new file mode 100755 index 0000000..b75791d --- /dev/null +++ b/tabby-runner/package.json @@ -0,0 +1,6 @@ +{ + "dependencies": { + "child_process": "^1.0.2", + "terminate": "^2.8.0" + } +} diff --git a/tabby-runner/run-client.sh b/tabby-runner/run-client.sh new file mode 100755 index 0000000..9a95b4c --- /dev/null +++ b/tabby-runner/run-client.sh @@ -0,0 +1 @@ +TABBY_ROOT='/media/aurelia/dev/tabby/' ./tabby serve --model /media/aurelia/dev/tabby/models/deepseek-quant --chat-model /media/aurelia/dev/tabby/models/llama3.2-1b --device cuda diff --git a/tabby-runner/run.sh b/tabby-runner/run.sh new file mode 100755 index 0000000..c499cf0 --- /dev/null +++ b/tabby-runner/run.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +node index.js |
