Skip to content

Commit 0c84bb6

Browse files
committed
Updated
1 parent 26ea0f0 commit 0c84bb6

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

cmd/llm/complete.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ import (
1616
// TYPES
1717

1818
type CompleteCmd struct {
19-
Model string `arg:"" help:"Model name"`
20-
Prompt string `arg:"" optional:"" help:"Prompt"`
21-
File []string `type:"file" help:"Files to attach"`
22-
System string `flag:"system" help:"Set the system prompt"`
23-
NoStream bool `flag:"no-stream" help:"Do not stream output"`
19+
Model string `arg:"" help:"Model name"`
20+
Prompt string `arg:"" optional:"" help:"Prompt"`
21+
File []string `type:"file" short:"f" help:"Files to attach"`
22+
System string `flag:"system" help:"Set the system prompt"`
23+
NoStream bool `flag:"no-stream" help:"Do not stream output"`
24+
Format string `flag:"format" enum:"text,json" default:"text" help:"Output format. You may also need to specify the output in the system or user prompt."`
25+
Temperature *float64 `flag:"temperature" short:"t" help:"Temperature for sampling"`
2426
}
2527

2628
////////////////////////////////////////////////////////////////////////////////
@@ -98,5 +100,11 @@ func (cmd *CompleteCmd) opts() []llm.Opt {
98100
if cmd.System != "" {
99101
opts = append(opts, llm.WithSystemPrompt(cmd.System))
100102
}
103+
if cmd.Format == "json" {
104+
opts = append(opts, llm.WithFormat("json"))
105+
}
106+
if cmd.Temperature != nil {
107+
opts = append(opts, llm.WithTemperature(*cmd.Temperature))
108+
}
101109
return opts
102110
}

cmd/llm/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import (
2323
type Globals struct {
2424
// Debugging
2525
Debug bool `name:"debug" help:"Enable debug output"`
26-
Verbose bool `name:"verbose" help:"Enable verbose output"`
27-
Timeout time.Duration `name:"timeout" help:"Timeout for the command"`
26+
Verbose bool `name:"verbose" short:"v" help:"Enable verbose output"`
27+
Timeout time.Duration `name:"timeout" help:"Agent connection timeout"`
2828

2929
// Agents
3030
Ollama `embed:"" help:"Ollama configuration"`

opt.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package llm
33
import (
44
"encoding/json"
55
"io"
6+
"strings"
67
"time"
78
)
89

@@ -330,6 +331,12 @@ func WithSeed(v uint64) Opt {
330331
// Set format
331332
func WithFormat(v any) Opt {
332333
return func(o *Opts) error {
334+
if v_, ok := v.(string); ok {
335+
v_ = strings.TrimSpace(strings.ToLower(v_))
336+
if v_ == "json" {
337+
v = "json_object"
338+
}
339+
}
333340
o.Set("format", v)
334341
return nil
335342
}

0 commit comments

Comments
 (0)