Skip to content

Commit 6eb3ce3

Browse files
committed
Add option to generate titles
Signed-off-by: David Gageot <david.gageot@docker.com>
1 parent 9971eea commit 6eb3ce3

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

pkg/model/provider/clone.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ func CloneWithOptions(ctx context.Context, base Provider, opts ...options.Opt) P
1616
// Preserve existing options, then apply overrides. Later opts take precedence.
1717
baseOpts := options.FromModelOptions(config.ModelOptions)
1818
mergedOpts := append(baseOpts, opts...)
19+
mergedOpts = append(mergedOpts, options.WithGeneratingTitle())
1920

2021
clone, err := New(ctx, &config.ModelConfig, config.Env, mergedOpts...)
2122
if err != nil {

pkg/model/provider/options/options.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
type ModelOptions struct {
88
gateway string
99
structuredOutput *latest.StructuredOutput
10+
generatingTitle bool
1011
}
1112

1213
func (c *ModelOptions) Gateway() string {
@@ -17,6 +18,10 @@ func (c *ModelOptions) StructuredOutput() *latest.StructuredOutput {
1718
return c.structuredOutput
1819
}
1920

21+
func (c *ModelOptions) GeneratingTitle() bool {
22+
return c.generatingTitle
23+
}
24+
2025
type Opt func(*ModelOptions)
2126

2227
func WithGateway(gateway string) Opt {
@@ -31,6 +36,12 @@ func WithStructuredOutput(structuredOutput *latest.StructuredOutput) Opt {
3136
}
3237
}
3338

39+
func WithGeneratingTitle() Opt {
40+
return func(cfg *ModelOptions) {
41+
cfg.generatingTitle = true
42+
}
43+
}
44+
3445
// FromModelOptions converts a concrete ModelOptions value into a slice of
3546
// Opt configuration functions. Later Opts override earlier ones when applied.
3647
func FromModelOptions(m ModelOptions) []Opt {
@@ -41,5 +52,8 @@ func FromModelOptions(m ModelOptions) []Opt {
4152
if m.structuredOutput != nil {
4253
out = append(out, WithStructuredOutput(m.structuredOutput))
4354
}
55+
if m.generatingTitle {
56+
out = append(out, WithGeneratingTitle())
57+
}
4458
return out
4559
}

0 commit comments

Comments
 (0)