Skip to content

Commit d6dd058

Browse files
committed
Updated
1 parent 3334010 commit d6dd058

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

context.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ type Context interface {
1616
// Generate a response from a user prompt (with attachments)
1717
FromUser(context.Context, string, ...Opt) (Context, error)
1818

19-
// Generate a response from a tool, passing the call identifier or funtion name, and the result
20-
FromTool(context.Context, string, any) (Context, error)
19+
// Generate a response from a tool, passing the call identifier or function name, and the result
20+
FromTool(context.Context, string, any, ...Opt) (Context, error)
2121
}

pkg/ollama/session.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,14 @@ func (s *session) FromUser(ctx context.Context, prompt string, opts ...llm.Opt)
7979
response.seq[len(response.seq)-1] = user
8080
}
8181

82+
// The options come from the session options and the user options
83+
chatopts := make([]llm.Opt, 0, len(s.opts)+len(opts))
84+
chatopts = append(chatopts, s.opts...)
85+
chatopts = append(chatopts, opts...)
86+
8287
// Call the 'chat' method
8388
client := s.model.client
84-
r, err := client.Chat(ctx, response, response.opts...)
89+
r, err := client.Chat(ctx, response, chatopts...)
8590
if err != nil {
8691
return nil, err
8792
} else {
@@ -93,7 +98,7 @@ func (s *session) FromUser(ctx context.Context, prompt string, opts ...llm.Opt)
9398
}
9499

95100
// Generate a response from a tool calling result
96-
func (s *session) FromTool(ctx context.Context, call string, result any) (llm.Context, error) {
101+
func (s *session) FromTool(ctx context.Context, call string, result any, opts ...llm.Opt) (llm.Context, error) {
97102
// Make a new session
98103
response := new(session)
99104
response.model = s.model
@@ -107,8 +112,13 @@ func (s *session) FromTool(ctx context.Context, call string, result any) (llm.Co
107112
response.seq[len(response.seq)-1] = message
108113
}
109114

115+
// The options come from the session options and the user options
116+
chatopts := make([]llm.Opt, 0, len(s.opts)+len(opts))
117+
chatopts = append(chatopts, s.opts...)
118+
chatopts = append(chatopts, opts...)
119+
110120
// Call the 'chat' method
111-
r, err := s.model.client.Chat(ctx, response, response.opts...)
121+
r, err := s.model.client.Chat(ctx, response, chatopts...)
112122
if err != nil {
113123
return nil, err
114124
} else {

0 commit comments

Comments
 (0)