-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from yusufcanb/release/1.0-rc1
Release 1.0-rc1
- Loading branch information
Showing
50 changed files
with
1,115 additions
and
1,108 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
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 @@ | ||
1.0-rc1 |
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,8 @@ | ||
FROM codellama:7b | ||
|
||
PARAMETER temperature 0.25 | ||
PARAMETER top_p 0.2 | ||
PARAMETER top_k 25 | ||
PARAMETER seed 42 | ||
|
||
SYSTEM You are a command line application which helps user to get brief explanations for shell commands. You will be explaining given executable shell command to user with shortest possible explanation. If given input is not a shell command, you will respond with "I can only explain shell commands. Please provide a shell command to explain". You will never respond any question out of shell command explanation context. |
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,8 @@ | ||
FROM codellama:7b | ||
|
||
PARAMETER temperature 0.1 | ||
PARAMETER top_p 0.5 | ||
PARAMETER top_k 40 | ||
PARAMETER seed 1 | ||
|
||
SYSTEM You are software program specifically for Command Line Interface usage. User will ask you some thing that can be convertible to a UNIX or Windows command. You won't provide information or explanations and your output will be just an executable shell command inside three backticks. |
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,64 @@ | ||
package app | ||
|
||
import ( | ||
_ "embed" | ||
ollama "github.com/jmorganca/ollama/api" | ||
"github.com/yusufcanb/tlm/config" | ||
"github.com/yusufcanb/tlm/explain" | ||
"github.com/yusufcanb/tlm/install" | ||
"github.com/yusufcanb/tlm/suggest" | ||
|
||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
//go:embed Modelfile.explain | ||
var explainModelfile string | ||
|
||
//go:embed Modelfile.suggest | ||
var suggestModelfile string | ||
|
||
type TlmApp struct { | ||
App *cli.App | ||
|
||
explainModelfile string | ||
suggestModelfile string | ||
} | ||
|
||
func New(version string) *TlmApp { | ||
con := config.New() | ||
con.LoadOrCreateConfig() | ||
|
||
o, _ := ollama.ClientFromEnvironment() | ||
sug := suggest.New(o, suggestModelfile) | ||
exp := explain.New(o, explainModelfile) | ||
ins := install.New(o, suggestModelfile, explainModelfile) | ||
|
||
cliApp := &cli.App{ | ||
Name: "tlm", | ||
Usage: "local terminal companion powered by CodeLLaMa.", | ||
Version: version, | ||
HideHelpCommand: true, | ||
Action: func(c *cli.Context) error { | ||
return cli.ShowAppHelp(c) | ||
}, | ||
Commands: []*cli.Command{ | ||
sug.Command(), | ||
exp.Command(), | ||
ins.Command(), | ||
con.Command(), | ||
&cli.Command{ | ||
Name: "version", | ||
Aliases: []string{"v"}, | ||
Usage: "print version.", | ||
Action: func(c *cli.Context) error { | ||
cli.ShowVersion(c) | ||
return nil | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
return &TlmApp{ | ||
App: cliApp, | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,41 @@ | ||
Output config.gif | ||
|
||
Set Theme "GitHub Dark" | ||
Set Margin 60 | ||
Set MarginFill "#4e8eff" | ||
|
||
Set Width 1400 | ||
Set Height 1000 | ||
Set FontSize 26 | ||
|
||
Type "tlm config" | ||
Sleep 1s | ||
Enter | ||
Sleep 1s | ||
|
||
# host | ||
Sleep 500ms | ||
Enter | ||
Sleep 500ms | ||
|
||
# shell | ||
Up | ||
Sleep 500ms | ||
Enter | ||
Sleep 500ms | ||
|
||
# suggest | ||
Sleep 500ms | ||
Up | ||
Sleep 500ms | ||
Enter | ||
Sleep 500ms | ||
|
||
# explain | ||
Sleep 500ms | ||
Down | ||
Sleep 500ms | ||
Enter | ||
Sleep 500ms | ||
|
||
Sleep 4s |
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,14 @@ | ||
Output explain.gif | ||
|
||
Set Theme "GitHub Dark" | ||
Set Margin 60 | ||
Set MarginFill "#4e8eff" | ||
|
||
Set Width 1401 | ||
Set Height 1000 | ||
Set FontSize 26 | ||
|
||
Type "tlm explain 'wmic path win32_VideoController get name,status,adapterram'" | ||
Sleep 250ms | ||
Enter | ||
Sleep 35 |
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,25 @@ | ||
Output suggest.gif | ||
|
||
Set Theme "GitHub Dark" | ||
Set Margin 60 | ||
Set MarginFill "#4e8eff" | ||
|
||
Set Width 1401 | ||
Set Height 1000 | ||
Set FontSize 26 | ||
|
||
Type "tlm suggest 'list all network interfaces but only their ip addresses'" | ||
Sleep 250ms | ||
Enter | ||
Sleep 8s | ||
|
||
Enter | ||
Sleep 500ms | ||
|
||
Up | ||
Sleep 250ms | ||
Up | ||
Sleep 250ms | ||
Enter | ||
|
||
Sleep 8s |
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 was deleted.
Oops, something went wrong.
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,58 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"github.com/spf13/viper" | ||
"github.com/yusufcanb/tlm/shell" | ||
"log" | ||
"os" | ||
"path" | ||
) | ||
|
||
var defaultLLMHost = "http://localhost:11434" | ||
|
||
func isExists(path string) bool { | ||
if _, err := os.Stat(path); os.IsNotExist(err) { | ||
return false | ||
} | ||
return true | ||
} | ||
|
||
func (c *Config) LoadOrCreateConfig() { | ||
viper.SetConfigName(".tlm") | ||
viper.SetConfigType("yaml") | ||
viper.AddConfigPath("$HOME") | ||
|
||
homeDir, err := os.UserHomeDir() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
configPath := path.Join(homeDir, ".tlm.yaml") | ||
if !isExists(configPath) { | ||
viper.Set("shell", shell.GetShell()) | ||
|
||
viper.Set("llm.host", defaultLLMHost) | ||
viper.Set("llm.suggestion", "balanced") | ||
viper.Set("llm.explain", "balanced") | ||
|
||
err := os.Setenv("OLLAMA_HOST", defaultLLMHost) | ||
if err != nil { | ||
fmt.Printf(shell.Err()+" error writing config file, %s", err) | ||
} | ||
|
||
if err := viper.WriteConfigAs(path.Join(homeDir, ".tlm.yaml")); err != nil { | ||
fmt.Printf(shell.Err()+" error writing config file, %s", err) | ||
} | ||
} | ||
|
||
err = viper.ReadInConfig() | ||
if err != nil { | ||
log.Fatalf("Error reading config file, %s", err) | ||
} | ||
|
||
err = os.Setenv("OLLAMA_HOST", viper.GetString("llm.host")) | ||
if err != nil { | ||
fmt.Printf(shell.Err()+" %s", err) | ||
} | ||
} |
Oops, something went wrong.