Skip to content

Commit 9e30bd3

Browse files
committed
Updates
1 parent e559fb2 commit 9e30bd3

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

cmd/llm/chat.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff 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

cmd/llm/models.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
}

pkg/mistral/model.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
// TYPES
1313

1414
type model struct {
15-
*Client
16-
meta Model
15+
*Client `json:"-"`
16+
meta Model
1717
}
1818

1919
type Model struct {

pkg/ollama/model.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616

1717
// model is the implementation of the llm.Model interface
1818
type 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+
6367
func (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
}

0 commit comments

Comments
 (0)