-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
43 lines (36 loc) · 1.03 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package conversation
import (
"context"
"github.com/otiai10/openaigo"
)
// Option is the options for the conversation.
type Option func(c *Conversation) error
// WithInitialPrompt allow to load an initial prompt to guide your model's behavior throughout the conversation.
// The prompt will be written as "system" role.
func WithInitialPrompt(s string) Option {
return func(c *Conversation) error {
c.History = append(c.History, openaigo.ChatMessage{Role: roleSystem, Content: s})
return nil
}
}
// WithModel allows to override the default model (gpt-3.5-turbo).
func WithModel(model string) Option {
return func(c *Conversation) error {
c.model = model
return nil
}
}
// WithHistory allows to inject an history in the conversation.
func WithHistory(msg []openaigo.ChatMessage) Option {
return func(c *Conversation) error {
c.History = msg
return nil
}
}
// WithContext associate a context to the conversation.
func WithContext(ctx context.Context) Option {
return func(c *Conversation) error {
c.ctx = ctx
return nil
}
}