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 {
1919 Model string `arg:"" help:"Model name"`
2020 NoStream bool `flag:"nostream" help:"Disable streaming"`
2121 NoTools bool `flag:"nostream" help:"Disable tool calling"`
22+ Prompt string `flag:"prompt" help:"Set the initial user prompt"`
2223 System string `flag:"system" help:"Set the system prompt"`
2324}
2425
@@ -60,11 +61,17 @@ func (cmd *ChatCmd) Run(globals *Globals) error {
6061
6162 // Continue looping until end of input
6263 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+ }
6875 }
6976
7077 // Ignore empty input
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ func (*ListAgentsCmd) Run(globals *Globals) error {
6060 return fmt .Errorf ("No agents found" )
6161 }
6262
63- var agents []string
63+ agents := make ( []string , 0 , len ( agent . Agents ()))
6464 for _ , agent := range agent .Agents () {
6565 agents = append (agents , agent .Name ())
6666 }
Original file line number Diff line number Diff line change @@ -12,8 +12,8 @@ import (
1212// TYPES
1313
1414type model struct {
15- * Client
16- meta Model
15+ * Client `json:"-"`
16+ meta Model
1717}
1818
1919type Model struct {
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import (
1616
1717// model is the implementation of the llm.Model interface
1818type model struct {
19- * Client
19+ * Client `json:"-"`
2020 ModelMeta
2121}
2222
@@ -60,8 +60,12 @@ type PullStatus struct {
6060///////////////////////////////////////////////////////////////////////////////
6161// STRINGIFY
6262
63+ func (m model ) MarshalJSON () ([]byte , error ) {
64+ return json .Marshal (m .ModelMeta )
65+ }
66+
6367func (m model ) String () string {
64- data , err := json .MarshalIndent (m . ModelMeta , "" , " " )
68+ data , err := json .MarshalIndent (m , "" , " " )
6569 if err != nil {
6670 return err .Error ()
6771 }
You can’t perform that action at this time.
0 commit comments