• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kshard / chatter / 16538940978

26 Jul 2025 10:35AM UTC coverage: 67.584% (+44.9%) from 22.674%
16538940978

Pull #53

github

fogfish
update license
Pull Request #53: Enable multi-content I/O within prompts & responses

596 of 837 new or added lines in 27 files covered. (71.21%)

2 existing lines in 2 files now uncovered.

884 of 1308 relevant lines covered (67.58%)

0.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/provider/bedrock/foundation/converse/service.go
1
//
2
// Copyright (C) 2024 - 2025 Dmitry Kolesnikov
3
//
4
// This file may be modified and distributed under the terms
5
// of the MIT license.  See the LICENSE file for details.
6
// https://github.com/kshard/chatter
7
//
8

9
package converse
10

11
import (
12
        "context"
13

14
        "github.com/aws/aws-sdk-go-v2/aws"
15
        "github.com/aws/aws-sdk-go-v2/config"
16
        "github.com/aws/aws-sdk-go-v2/service/bedrockruntime"
17
        "github.com/fogfish/opts"
18
        "github.com/kshard/chatter"
19
        "github.com/kshard/chatter/aio/provider"
20
)
21

22
//
23
// Configuration options for the Bedrock Converse
24
//
25

26
type Option = opts.Option[Service]
27

28
const defaultRegion = "us-west-2"
29

30
var (
31
        // Use aws.Config to config the client
32
        WithConfig = opts.FMap(optsFromConfig)
33

34
        // Use region for aws.Config
35
        WithRegion = opts.FMap(optsFromRegion)
36

37
        // Set AWS Bedrock Runtime
38
        WithRuntime = opts.ForType[Service, Runtime]()
39

40
        // Set command-line registry
41
        WithRegistry = opts.ForType[Service, chatter.Registry]()
42
)
43

NEW
44
func optsFromRegion(c *Service, region string) error {
×
NEW
45
        cfg, err := config.LoadDefaultConfig(
×
NEW
46
                context.Background(),
×
NEW
47
                config.WithRegion(region),
×
NEW
48
        )
×
NEW
49
        if err != nil {
×
NEW
50
                return err
×
NEW
51
        }
×
52

NEW
53
        return optsFromConfig(c, cfg)
×
54
}
55

NEW
56
func optsFromConfig(c *Service, cfg aws.Config) (err error) {
×
NEW
57
        if c.api == nil {
×
NEW
58
                c.api = bedrockruntime.NewFromConfig(cfg)
×
NEW
59
        }
×
60

NEW
61
        return
×
62
}
63

64
type Runtime interface {
65
        Converse(ctx context.Context, params *bedrockruntime.ConverseInput, optFns ...func(*bedrockruntime.Options)) (*bedrockruntime.ConverseOutput, error)
66
}
67

68
type Service struct {
69
        api      Runtime
70
        registry chatter.Registry
71
}
72

73
var _ provider.Service[*bedrockruntime.ConverseInput, *bedrockruntime.ConverseOutput] = (*Service)(nil)
74

NEW
75
func (s *Service) Invoke(ctx context.Context, input *bedrockruntime.ConverseInput) (*bedrockruntime.ConverseOutput, error) {
×
NEW
76
        return s.api.Converse(ctx, input)
×
NEW
77
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc