@@ -2,6 +2,8 @@ package agent
22
33import (
44 // Packages
5+ "fmt"
6+
57 client "github.com/mutablelogic/go-client"
68 llm "github.com/mutablelogic/go-llm"
79 anthropic "github.com/mutablelogic/go-llm/pkg/anthropic"
@@ -15,9 +17,9 @@ type opt struct {
1517 agents map [string ]llm.Agent
1618 tools map [string ]llm.Tool
1719
18- // Selected agent
19- agent llm.Agent
20- opts []llm.Opt
20+ // Translated options for each agent implementation
21+ ollama [] llm.Opt
22+ anthropic []llm.Opt
2123}
2224
2325////////////////////////////////////////////////////////////////////////////////
@@ -35,28 +37,6 @@ func apply(opts ...llm.Opt) (*opt, error) {
3537 return o , nil
3638}
3739
38- // Translate options from general to agent-specific
39- func translate (agent llm.Agent , opts ... llm.Opt ) ([]llm.Opt , error ) {
40- o := new (opt )
41-
42- // Set agent
43- if agent == nil {
44- return nil , llm .ErrBadParameter .With ("agent" )
45- } else {
46- o .agent = agent
47- }
48-
49- // Apply options
50- for _ , opt := range opts {
51- if err := opt (o ); err != nil {
52- return nil , err
53- }
54- }
55-
56- // Return translated options
57- return o .opts , nil
58- }
59-
6040////////////////////////////////////////////////////////////////////////////////
6141// PUBLIC METHODS
6242
@@ -82,6 +62,7 @@ func WithAnthropic(key string, opts ...client.ClientOpt) llm.Opt {
8262 }
8363}
8464
65+ // Append tools
8566func WithTools (tools ... llm.Tool ) llm.Opt {
8667 return func (o any ) error {
8768 for _ , tool := range tools {
@@ -96,6 +77,19 @@ func WithTools(tools ...llm.Tool) llm.Opt {
9677 }
9778}
9879
80+ // Set streaming function
81+ func WithStream (v bool ) llm.Opt {
82+ return func (o any ) error {
83+ o .(* opt ).ollama = append (o .(* opt ).ollama , ollama .WithStream (func (r * ollama.Response ) {
84+ fmt .Println (r )
85+ }))
86+ o .(* opt ).anthropic = append (o .(* opt ).anthropic , anthropic .WithStream (func (r * anthropic.Response ) {
87+ fmt .Println (r )
88+ }))
89+ return nil
90+ }
91+ }
92+
9993////////////////////////////////////////////////////////////////////////////////
10094// PRIVATE METHODS
10195
0 commit comments