Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
djthorpe committed Feb 2, 2025
1 parent e559fb2 commit 9e30bd3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
17 changes: 12 additions & 5 deletions cmd/llm/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type ChatCmd struct {
Model string `arg:"" help:"Model name"`
NoStream bool `flag:"nostream" help:"Disable streaming"`
NoTools bool `flag:"nostream" help:"Disable tool calling"`
Prompt string `flag:"prompt" help:"Set the initial user prompt"`
System string `flag:"system" help:"Set the system prompt"`
}

Expand Down Expand Up @@ -60,11 +61,17 @@ func (cmd *ChatCmd) Run(globals *Globals) error {

// Continue looping until end of input
for {
input, err := globals.term.ReadLine(model.Name() + "> ")
if errors.Is(err, io.EOF) {
return nil
} else if err != nil {
return err
var input string
if cmd.Prompt != "" {
input = cmd.Prompt
cmd.Prompt = ""
} else {
input, err = globals.term.ReadLine(model.Name() + "> ")
if errors.Is(err, io.EOF) {
return nil
} else if err != nil {
return err
}
}

// Ignore empty input
Expand Down
2 changes: 1 addition & 1 deletion cmd/llm/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (*ListAgentsCmd) Run(globals *Globals) error {
return fmt.Errorf("No agents found")
}

var agents []string
agents := make([]string, 0, len(agent.Agents()))
for _, agent := range agent.Agents() {
agents = append(agents, agent.Name())
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/mistral/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
// TYPES

type model struct {
*Client
meta Model
*Client `json:"-"`
meta Model
}

type Model struct {
Expand Down
8 changes: 6 additions & 2 deletions pkg/ollama/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

// model is the implementation of the llm.Model interface
type model struct {
*Client
*Client `json:"-"`
ModelMeta
}

Expand Down Expand Up @@ -60,8 +60,12 @@ type PullStatus struct {
///////////////////////////////////////////////////////////////////////////////
// STRINGIFY

func (m model) MarshalJSON() ([]byte, error) {
return json.Marshal(m.ModelMeta)
}

func (m model) String() string {
data, err := json.MarshalIndent(m.ModelMeta, "", " ")
data, err := json.MarshalIndent(m, "", " ")
if err != nil {
return err.Error()
}
Expand Down

0 comments on commit 9e30bd3

Please sign in to comment.