File tree Expand file tree Collapse file tree 4 files changed +21
-10
lines changed Expand file tree Collapse file tree 4 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ type ChatCmd struct {
19
19
Model string `arg:"" help:"Model name"`
20
20
NoStream bool `flag:"nostream" help:"Disable streaming"`
21
21
NoTools bool `flag:"nostream" help:"Disable tool calling"`
22
+ Prompt string `flag:"prompt" help:"Set the initial user prompt"`
22
23
System string `flag:"system" help:"Set the system prompt"`
23
24
}
24
25
@@ -60,11 +61,17 @@ func (cmd *ChatCmd) Run(globals *Globals) error {
60
61
61
62
// Continue looping until end of input
62
63
for {
63
- input , err := globals .term .ReadLine (model .Name () + "> " )
64
- if errors .Is (err , io .EOF ) {
65
- return nil
66
- } else if err != nil {
67
- return err
64
+ var input string
65
+ if cmd .Prompt != "" {
66
+ input = cmd .Prompt
67
+ cmd .Prompt = ""
68
+ } else {
69
+ input , err = globals .term .ReadLine (model .Name () + "> " )
70
+ if errors .Is (err , io .EOF ) {
71
+ return nil
72
+ } else if err != nil {
73
+ return err
74
+ }
68
75
}
69
76
70
77
// Ignore empty input
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ func (*ListAgentsCmd) Run(globals *Globals) error {
60
60
return fmt .Errorf ("No agents found" )
61
61
}
62
62
63
- var agents []string
63
+ agents := make ( []string , 0 , len ( agent . Agents ()))
64
64
for _ , agent := range agent .Agents () {
65
65
agents = append (agents , agent .Name ())
66
66
}
Original file line number Diff line number Diff line change @@ -12,8 +12,8 @@ import (
12
12
// TYPES
13
13
14
14
type model struct {
15
- * Client
16
- meta Model
15
+ * Client `json:"-"`
16
+ meta Model
17
17
}
18
18
19
19
type Model struct {
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import (
16
16
17
17
// model is the implementation of the llm.Model interface
18
18
type model struct {
19
- * Client
19
+ * Client `json:"-"`
20
20
ModelMeta
21
21
}
22
22
@@ -60,8 +60,12 @@ type PullStatus struct {
60
60
///////////////////////////////////////////////////////////////////////////////
61
61
// STRINGIFY
62
62
63
+ func (m model ) MarshalJSON () ([]byte , error ) {
64
+ return json .Marshal (m .ModelMeta )
65
+ }
66
+
63
67
func (m model ) String () string {
64
- data , err := json .MarshalIndent (m . ModelMeta , "" , " " )
68
+ data , err := json .MarshalIndent (m , "" , " " )
65
69
if err != nil {
66
70
return err .Error ()
67
71
}
You can’t perform that action at this time.
0 commit comments