File tree Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ require (
8
8
github.com/acorn-io/broadcaster v0.0.0-20240105011354-bfadd4a7b45d
9
9
github.com/acorn-io/cmd v0.0.0-20240203032901-e9e631185ddb
10
10
github.com/adrg/xdg v0.4.0
11
+ github.com/fatih/color v1.16.0
11
12
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
12
13
github.com/hexops/autogold/v2 v2.1.0
13
14
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056
@@ -34,7 +35,6 @@ require (
34
35
github.com/connesc/cipherio v0.2.1 // indirect
35
36
github.com/davecgh/go-spew v1.1.1 // indirect
36
37
github.com/dsnet/compress v0.0.1 // indirect
37
- github.com/fatih/color v1.16.0 // indirect
38
38
github.com/go-logr/logr v1.4.1 // indirect
39
39
github.com/golang/snappy v0.0.4 // indirect
40
40
github.com/google/go-cmp v0.6.0 // indirect
Original file line number Diff line number Diff line change 7
7
"strings"
8
8
9
9
"github.com/acorn-io/cmd"
10
+ "github.com/fatih/color"
10
11
"github.com/gptscript-ai/gptscript/pkg/assemble"
11
12
"github.com/gptscript-ai/gptscript/pkg/builtin"
12
13
"github.com/gptscript-ai/gptscript/pkg/cache"
@@ -34,6 +35,7 @@ type GPTScript struct {
34
35
CacheOptions
35
36
OpenAIOptions
36
37
DisplayOptions
38
+ Color * bool `usage:"Use color in output (default true)" default:"true"`
37
39
Confirm bool `usage:"Prompt before running potentially dangerous commands"`
38
40
Debug bool `usage:"Enable debug logging"`
39
41
Quiet * bool `usage:"No output logging (set --quiet=false to force on even when there is no TTY)" short:"q"`
@@ -113,6 +115,10 @@ func (r *GPTScript) Pre(*cobra.Command, []string) error {
113
115
}
114
116
115
117
func (r * GPTScript ) Run (cmd * cobra.Command , args []string ) error {
118
+ if r .Color != nil {
119
+ color .NoColor = ! * r .Color
120
+ }
121
+
116
122
gptOpt := gptscript.Options {
117
123
Cache : cache .Options (r .CacheOptions ),
118
124
OpenAI : openai .Options (r .OpenAIOptions ),
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ package types
3
3
import (
4
4
"fmt"
5
5
"strings"
6
+
7
+ "github.com/fatih/color"
6
8
)
7
9
8
10
type CompletionRequest struct {
@@ -81,7 +83,7 @@ func (in CompletionMessage) String() string {
81
83
}
82
84
buf .WriteString (content .Text )
83
85
if content .ToolCall != nil {
84
- buf .WriteString (fmt .Sprintf ("tool call %s -> %s" , content .ToolCall .Function .Name , content .ToolCall .Function .Arguments ))
86
+ buf .WriteString (fmt .Sprintf ("tool call %s -> %s" , color . GreenString ( content .ToolCall .Function .Name ) , content .ToolCall .Function .Arguments ))
85
87
}
86
88
}
87
89
return buf .String ()
You can’t perform that action at this time.
0 commit comments