Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
hupe1980 committed Dec 8, 2023
1 parent 681b4d5 commit f8b21b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
28 changes: 14 additions & 14 deletions retriever/bedrock.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ import (
"github.com/hupe1980/golc/schema"
)

// Compile time check to ensure BedrockKnowledgeBases satisfies the Retriever interface.
var _ schema.Retriever = (*BedrockKnowledgeBases)(nil)
// Compile time check to ensure BedrockKnowledgeBase satisfies the Retriever interface.
var _ schema.Retriever = (*BedrockKnowledgeBase)(nil)

// BedrockAgentRuntimeClient is an interface representing the Bedrock Agent Runtime client.
type BedrockAgentRuntimeClient interface {
Retrieve(context.Context, *bedrockagentruntime.RetrieveInput, ...func(*bedrockagentruntime.Options)) (*bedrockagentruntime.RetrieveOutput, error)
}

// BedrockKnowledgeBasesOptions represents the options for configuring BedrockKnowledgeBases.
type BedrockKnowledgeBasesOptions struct {
// BedrockKnowledgeBaseOptions represents the options for configuring BedrockKnowledgeBase.
type BedrockKnowledgeBaseOptions struct {
*schema.CallbackOptions

// RetrievalConfiguration provides search parameters for retrieving from knowledge base.
RetrievalConfiguration types.KnowledgeBaseRetrievalConfiguration
}

// BedrockKnowledgeBases is a retriever implementation for retrieving documents from a knowledge base using the Bedrock Agent Runtime client.
type BedrockKnowledgeBases struct {
// BedrockKnowledgeBase is a retriever implementation for retrieving documents from a knowledge base using the Bedrock Agent Runtime client.
type BedrockKnowledgeBase struct {
client BedrockAgentRuntimeClient
knowledgeBaseID string
opts BedrockKnowledgeBasesOptions
opts BedrockKnowledgeBaseOptions
}

// NewBedrockKnowledgeBases creates a new BedrockKnowledgeBases retriever with the specified client, knowledge base ID, and options.
func NewBedrockKnowledgeBases(client BedrockAgentRuntimeClient, knowledgeBaseID string, optFns ...func(o *BedrockKnowledgeBasesOptions)) *BedrockKnowledgeBases {
opts := BedrockKnowledgeBasesOptions{
// NewBedrockKnowledgeBase creates a new BedrockKnowledgeBase retriever with the specified client, knowledge base ID, and options.
func NewBedrockKnowledgeBase(client BedrockAgentRuntimeClient, knowledgeBaseID string, optFns ...func(o *BedrockKnowledgeBaseOptions)) *BedrockKnowledgeBase {
opts := BedrockKnowledgeBaseOptions{
CallbackOptions: &schema.CallbackOptions{
Verbose: golc.Verbose,
},
Expand All @@ -51,15 +51,15 @@ func NewBedrockKnowledgeBases(client BedrockAgentRuntimeClient, knowledgeBaseID
fn(&opts)
}

return &BedrockKnowledgeBases{
return &BedrockKnowledgeBase{
client: client,
knowledgeBaseID: knowledgeBaseID,
opts: opts,
}
}

// GetRelevantDocuments retrieves relevant documents from the knowledge base based on the given query.
func (r *BedrockKnowledgeBases) GetRelevantDocuments(ctx context.Context, query string) ([]schema.Document, error) {
func (r *BedrockKnowledgeBase) GetRelevantDocuments(ctx context.Context, query string) ([]schema.Document, error) {
query = strings.TrimSpace(query)

docs := []schema.Document{}
Expand Down Expand Up @@ -92,11 +92,11 @@ func (r *BedrockKnowledgeBases) GetRelevantDocuments(ctx context.Context, query
}

// Verbose returns the verbosity setting of the retriever.
func (r *BedrockKnowledgeBases) Verbose() bool {
func (r *BedrockKnowledgeBase) Verbose() bool {
return r.opts.CallbackOptions.Verbose
}

// Callbacks returns the registered callbacks of the retriever.
func (r *BedrockKnowledgeBases) Callbacks() []schema.Callback {
func (r *BedrockKnowledgeBase) Callbacks() []schema.Callback {
return r.opts.CallbackOptions.Callbacks
}
4 changes: 2 additions & 2 deletions retriever/bedrock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/stretchr/testify/assert"
)

func TestBedrockKnowledgeBases_GetRelevantDocuments(t *testing.T) {
func TestBedrockKnowledgeBase_GetRelevantDocuments(t *testing.T) {
// Test cases
tests := []struct {
name string
Expand Down Expand Up @@ -90,7 +90,7 @@ func TestBedrockKnowledgeBases_GetRelevantDocuments(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Create the retriever with the mock client
r := NewBedrockKnowledgeBases(&mockBedrockAgentRuntimeClient{
r := NewBedrockKnowledgeBase(&mockBedrockAgentRuntimeClient{
RetrieveOutput: tt.retrieveOutput,
RetrieveError: tt.retrieveError,
}, "knowledge-base-id")
Expand Down

0 comments on commit f8b21b9

Please sign in to comment.