Skip to content

Commit 18ae561

Browse files
committed
chore(openai): add comments.
1 parent 76ffe95 commit 18ae561

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

openai/options.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,51 @@
11
package openai
22

3-
// Option specifies instrumentation configuration options.
3+
// Option is an interface that specifies instrumentation configuration options.
44
type Option interface {
55
apply(*config)
66
}
77

8-
var _ Option = (*optionFunc)(nil)
9-
8+
// optionFunc is a type of function that can be used to implement the Option interface.
9+
// It takes a pointer to a config struct and modifies it.
1010
type optionFunc func(*config)
1111

12+
// Ensure that optionFunc satisfies the Option interface.
13+
var _ Option = (*optionFunc)(nil)
14+
15+
// The apply method of optionFunc type is implemented here to modify the config struct based on the function passed.
1216
func (o optionFunc) apply(c *config) {
1317
o(c)
1418
}
1519

20+
// WithToken is a function that returns an Option, which sets the token field of the config struct.
1621
func WithToken(val string) Option {
1722
return optionFunc(func(c *config) {
1823
c.token = val
1924
})
2025
}
2126

27+
// WithOrgID is a function that returns an Option, which sets the orgID field of the config struct.
2228
func WithOrgID(val string) Option {
2329
return optionFunc(func(c *config) {
2430
c.orgID = val
2531
})
2632
}
2733

34+
// WithModel is a function that returns an Option, which sets the model field of the config struct.
2835
func WithModel(val string) Option {
2936
return optionFunc(func(c *config) {
3037
c.model = val
3138
})
3239
}
3340

41+
// WithProxyURL is a function that returns an Option, which sets the proxyURL field of the config struct.
3442
func WithProxyURL(val string) Option {
3543
return optionFunc(func(c *config) {
3644
c.proxyURL = val
3745
})
3846
}
3947

48+
// config is a struct that stores configuration options for the instrumentation.
4049
type config struct {
4150
token string
4251
orgID string

0 commit comments

Comments
 (0)