Skip to content

Commit

Permalink
fix: lint and refactor, adding preallocations for ins/outs
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Nguyen <[email protected]>
  • Loading branch information
mikeee committed Nov 20, 2024
1 parent 8308a39 commit 86e3458
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions client/conversation.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package client

import (
"context"

runtimev1pb "github.com/dapr/dapr/pkg/proto/runtime/v1"
"google.golang.org/protobuf/types/known/anypb"
)
Expand Down Expand Up @@ -99,14 +100,13 @@ func WithTemperature(temp float64) conversationRequestOption {

// ConverseAlpha1 can invoke an LLM given a request created by the NewConversationRequest function.
func (c *GRPCClient) ConverseAlpha1(ctx context.Context, req conversationRequest, options ...conversationRequestOption) (*ConversationResponse, error) {

var cinputs []*runtimev1pb.ConversationInput
for _, i := range req.inputs {
cinputs = append(cinputs, &runtimev1pb.ConversationInput{
Message: i.Message,
Role: i.Role,
ScrubPII: i.ScrubPII,
})
var cinputs = make([]*runtimev1pb.ConversationInput, len(req.inputs))
for i, in := range req.inputs {
cinputs[i] = &runtimev1pb.ConversationInput{
Message: in.Message,
Role: in.Role,
ScrubPII: in.ScrubPII,
}
}

Check warning on line 110 in client/conversation.go

View check run for this annotation

Codecov / codecov/patch

client/conversation.go#L102-L110

Added lines #L102 - L110 were not covered by tests

for _, opt := range options {
Expand All @@ -130,12 +130,12 @@ func (c *GRPCClient) ConverseAlpha1(ctx context.Context, req conversationRequest
return nil, err
}

Check warning on line 131 in client/conversation.go

View check run for this annotation

Codecov / codecov/patch

client/conversation.go#L118-L131

Added lines #L118 - L131 were not covered by tests

var outputs []ConversationResult
for _, i := range resp.GetOutputs() {
outputs = append(outputs, ConversationResult{
Result: i.GetResult(),
Parameters: i.GetParameters(),
})
var outputs = make([]ConversationResult, len(resp.GetOutputs()))
for i, o := range resp.GetOutputs() {
outputs[i] = ConversationResult{
Result: o.GetResult(),
Parameters: o.GetParameters(),
}
}

Check warning on line 139 in client/conversation.go

View check run for this annotation

Codecov / codecov/patch

client/conversation.go#L133-L139

Added lines #L133 - L139 were not covered by tests

return &ConversationResponse{
Expand Down

0 comments on commit 86e3458

Please sign in to comment.