Skip to content

Commit 664c3fb

Browse files
chore: default to tui, support more flags
The tui supports disable-cache, cache-dir, and sub-tool now.
1 parent aa4cde6 commit 664c3fb

File tree

5 files changed

+20
-13
lines changed

5 files changed

+20
-13
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
1717
github.com/google/uuid v1.6.0
1818
github.com/gptscript-ai/chat-completion-client v0.0.0-20240515050533-bdef9f2226a9
19-
github.com/gptscript-ai/tui v0.0.0-20240531161317-ce32f93ac844
19+
github.com/gptscript-ai/tui v0.0.0-20240604045848-e01b0b7aab9f
2020
github.com/hexops/autogold/v2 v2.2.1
2121
github.com/hexops/valast v1.4.4
2222
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056
@@ -62,7 +62,7 @@ require (
6262
github.com/gookit/color v1.5.4 // indirect
6363
github.com/gorilla/css v1.0.0 // indirect
6464
github.com/gorilla/websocket v1.5.0 // indirect
65-
github.com/gptscript-ai/go-gptscript v0.0.0-20240531155932-57eeae840062 // indirect
65+
github.com/gptscript-ai/go-gptscript v0.0.0-20240604030145-39497c0575b3 // indirect
6666
github.com/hashicorp/errwrap v1.0.0 // indirect
6767
github.com/hashicorp/go-multierror v1.1.1 // indirect
6868
github.com/hexops/autogold v1.3.1 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWm
172172
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
173173
github.com/gptscript-ai/chat-completion-client v0.0.0-20240515050533-bdef9f2226a9 h1:s6nL/aokB1sJTqVXEjN0zFI5CJa66ubw9g68VTMzEw0=
174174
github.com/gptscript-ai/chat-completion-client v0.0.0-20240515050533-bdef9f2226a9/go.mod h1:7P/o6/IWa1KqsntVf68hSnLKuu3+xuqm6lYhch1w4jo=
175-
github.com/gptscript-ai/go-gptscript v0.0.0-20240531155932-57eeae840062 h1:30/1iOONBhw9WeCsoo4U74B+a20lATBFHFiVlpyk5oo=
176-
github.com/gptscript-ai/go-gptscript v0.0.0-20240531155932-57eeae840062/go.mod h1:h1yYzC0rgB5Kk7lwdba+Xs6cWkuJfLq6sPRna45OVG0=
177-
github.com/gptscript-ai/tui v0.0.0-20240531161317-ce32f93ac844 h1:c8sS5fCD3TXQZj94GDlQNR0zAw+1nuT3sYSH/Qo96+A=
178-
github.com/gptscript-ai/tui v0.0.0-20240531161317-ce32f93ac844/go.mod h1:G51xpKSFH0g1hG1s9J8vxj7NL6x43KJxZKM+77rt79s=
175+
github.com/gptscript-ai/go-gptscript v0.0.0-20240604030145-39497c0575b3 h1:mXLpCzEg4DoOeFZt6w99QFh9n60UwpRGGG0c+aaT+5k=
176+
github.com/gptscript-ai/go-gptscript v0.0.0-20240604030145-39497c0575b3/go.mod h1:h1yYzC0rgB5Kk7lwdba+Xs6cWkuJfLq6sPRna45OVG0=
177+
github.com/gptscript-ai/tui v0.0.0-20240604045848-e01b0b7aab9f h1:7dCE0E/y3y3p1BPSQGQ4mtsz5cWWl0FbXfCCDCf57SI=
178+
github.com/gptscript-ai/tui v0.0.0-20240604045848-e01b0b7aab9f/go.mod h1:ybD/8QfwaMiK2QUSnnTxgzrIaXRgipowU4pW1qxgNJ8=
179179
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
180180
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
181181
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=

pkg/cli/gptscript.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type GPTScript struct {
7070
ForceSequential bool `usage:"Force parallel calls to run sequentially"`
7171
Workspace string `usage:"Directory to use for the workspace, if specified it will not be deleted on exit"`
7272
UI bool `usage:"Launch the UI" local:"true" name:"ui"`
73-
TUI bool `usage:"Launch the TUI" local:"true" name:"tui"`
73+
DisableTUI bool `usage:"Don't use chat TUI but instead verbose output" local:"true" name:"disable-tui"`
7474

7575
readData []byte
7676
}
@@ -438,9 +438,14 @@ func (r *GPTScript) Run(cmd *cobra.Command, args []string) (retErr error) {
438438
}
439439

440440
if prg.IsChat() || r.ForceChat {
441-
if r.TUI {
442-
return tui.Run(cmd.Context(), args[0], r.Workspace, strings.Join(args[1:], " "), tui.RunOptions{
441+
if !r.DisableTUI && !r.Debug && !r.DebugMessages {
442+
return tui.Run(cmd.Context(), args[0], tui.RunOptions{
443443
TrustedRepoPrefixes: []string{"github.com/gptscript-ai/context"},
444+
DisableCache: r.DisableCache,
445+
Input: strings.Join(args[1:], " "),
446+
CacheDir: r.CacheDir,
447+
SubTool: r.SubTool,
448+
Workspace: r.Workspace,
444449
})
445450
}
446451
return chat.Start(cmd.Context(), nil, gptScript, func() (types.Program, error) {

pkg/mvl/log.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ func (f formatter) Format(entry *logrus.Entry) ([]byte, error) {
5353
if i, ok := entry.Data["request"]; ok && i != "" {
5454
msg += fmt.Sprintf(" [request=%s]", i)
5555
}
56+
if i, ok := entry.Data["cached"]; ok && i == true {
57+
msg += " [cached]"
58+
}
5659
if i, ok := entry.Data["response"]; ok && i != "" {
5760
msg += fmt.Sprintf(" [response=%s]", i)
5861
}

pkg/openai/client.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,16 +369,15 @@ func (c *Client) Call(ctx context.Context, messageRequest types.CompletionReques
369369
result.Role = types.CompletionMessageRoleTypeAssistant
370370
}
371371

372-
var usage types.Usage
373-
if !cacheResponse {
374-
usage = result.Usage
372+
if cacheResponse {
373+
result.Usage = types.Usage{}
375374
}
376375

377376
status <- types.CompletionStatus{
378377
CompletionID: id,
379378
Chunks: response,
380379
Response: result,
381-
Usage: usage,
380+
Usage: result.Usage,
382381
Cached: cacheResponse,
383382
}
384383

0 commit comments

Comments
 (0)