Skip to content

Commit 63b692b

Browse files
committed
Temporarily removed anthropic
1 parent 2b5ecde commit 63b692b

File tree

3 files changed

+27
-23
lines changed

3 files changed

+27
-23
lines changed

cmd/llm/chat.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
type ChatCmd struct {
1919
Model string `arg:"" help:"Model name"`
2020
NoStream bool `flag:"nostream" help:"Disable streaming"`
21+
NoTools bool `flag:"nostream" help:"Disable tool calling"`
2122
System string `flag:"system" help:"Set the system prompt"`
2223
}
2324

@@ -39,16 +40,17 @@ func (cmd *ChatCmd) Run(globals *Globals) error {
3940
// Set the options
4041
opts := []llm.Opt{}
4142
if !cmd.NoStream {
42-
opts = append(opts, llm.WithStream(func(cc llm.ContextContent) {
43-
if text := cc.Text(); text != "" {
44-
fmt.Println(text)
43+
opts = append(opts, llm.WithStream(func(cc llm.Completion) {
44+
if text := cc.Text(0); text != "" {
45+
text = strings.ReplaceAll(text, "\n", " ")
46+
fmt.Print("\r" + text)
4547
}
4648
}))
4749
}
4850
if cmd.System != "" {
4951
opts = append(opts, llm.WithSystemPrompt(cmd.System))
5052
}
51-
if globals.toolkit != nil {
53+
if globals.toolkit != nil && !cmd.NoTools {
5254
opts = append(opts, llm.WithToolKit(globals.toolkit))
5355
}
5456

@@ -77,12 +79,12 @@ func (cmd *ChatCmd) Run(globals *Globals) error {
7779

7880
// Repeat call tools until no more calls are made
7981
for {
80-
calls := session.ToolCalls()
82+
calls := session.ToolCalls(0)
8183
if len(calls) == 0 {
8284
break
8385
}
84-
if session.Text() != "" {
85-
globals.term.Println(session.Text())
86+
if session.Text(0) != "" {
87+
globals.term.Println(session.Text(0))
8688
} else {
8789
var names []string
8890
for _, call := range calls {
@@ -98,7 +100,7 @@ func (cmd *ChatCmd) Run(globals *Globals) error {
98100
}
99101

100102
// Print the response
101-
globals.term.Println("\n" + session.Text() + "\n")
103+
globals.term.Println("\n" + session.Text(0) + "\n")
102104
}
103105
})
104106
}

cmd/llm/main.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
client "github.com/mutablelogic/go-client"
1313
llm "github.com/mutablelogic/go-llm"
1414
agent "github.com/mutablelogic/go-llm/pkg/agent"
15-
"github.com/mutablelogic/go-llm/pkg/newsapi"
16-
"github.com/mutablelogic/go-llm/pkg/tool"
15+
newsapi "github.com/mutablelogic/go-llm/pkg/newsapi"
16+
tool "github.com/mutablelogic/go-llm/pkg/tool"
1717
)
1818

1919
////////////////////////////////////////////////////////////////////////////////
@@ -107,9 +107,11 @@ func main() {
107107
if cli.OllamaEndpoint != "" {
108108
opts = append(opts, agent.WithOllama(cli.OllamaEndpoint, clientopts...))
109109
}
110-
if cli.AnthropicKey != "" {
111-
opts = append(opts, agent.WithAnthropic(cli.AnthropicKey, clientopts...))
112-
}
110+
/*
111+
if cli.AnthropicKey != "" {
112+
opts = append(opts, agent.WithAnthropic(cli.AnthropicKey, clientopts...))
113+
}
114+
*/
113115
if cli.MistralKey != "" {
114116
opts = append(opts, agent.WithMistral(cli.MistralKey, clientopts...))
115117
}

pkg/agent/opt.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
// Packages
55
client "github.com/mutablelogic/go-client"
66
llm "github.com/mutablelogic/go-llm"
7-
anthropic "github.com/mutablelogic/go-llm/pkg/anthropic"
87
mistral "github.com/mutablelogic/go-llm/pkg/mistral"
98
ollama "github.com/mutablelogic/go-llm/pkg/ollama"
109
)
@@ -23,17 +22,18 @@ func WithOllama(endpoint string, opts ...client.ClientOpt) llm.Opt {
2322
}
2423
}
2524

26-
func WithAnthropic(key string, opts ...client.ClientOpt) llm.Opt {
27-
return func(o *llm.Opts) error {
28-
client, err := anthropic.New(key, opts...)
29-
if err != nil {
30-
return err
31-
} else {
32-
return llm.WithAgent(client)(o)
25+
/*
26+
func WithAnthropic(key string, opts ...client.ClientOpt) llm.Opt {
27+
return func(o *llm.Opts) error {
28+
client, err := anthropic.New(key, opts...)
29+
if err != nil {
30+
return err
31+
} else {
32+
return llm.WithAgent(client)(o)
33+
}
3334
}
3435
}
35-
}
36-
36+
*/
3737
func WithMistral(key string, opts ...client.ClientOpt) llm.Opt {
3838
return func(o *llm.Opts) error {
3939
client, err := mistral.New(key, opts...)

0 commit comments

Comments
 (0)