Skip to content

Commit

Permalink
fix: cleanup convo example
Browse files Browse the repository at this point in the history
Signed-off-by: mikeee <[email protected]>
  • Loading branch information
mikeee committed Nov 5, 2024
1 parent 4b13ed0 commit d4dda30
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 21 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/test-on-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@ jobs:
build:
name: Test on ${{ matrix.gover }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
gover:
- "1.21"
- "1.22"
env:
GOVER: ${{ matrix.gover }}
GOLANGCILINT_VER: v1.55.2

steps:
Expand All @@ -29,7 +22,7 @@ jobs:
- name: Setup
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVER }}
go-version-file: 'go.mod'

- name: Tidy
run: make tidy
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/validate_examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
GOPROXY: https://proxy.golang.org
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/master/install/install.sh
DAPR_CLI_REF: ${{ github.event.inputs.daprcli_commit }}
DAPR_REF: ${{ github.event.inputs.daprdapr_commit }}
DAPR_REF: 334ae9eea43d487a7b29a0e4aef904e3eba57a10
CHECKOUT_REPO: ${{ github.repository }}
CHECKOUT_REF: ${{ github.ref }}
outputs:
Expand Down Expand Up @@ -164,6 +164,7 @@ jobs:
[
"actor",
"configuration",
"conversation",
"crypto",
"dist-scheduler",
"grpc-service",
Expand Down
9 changes: 0 additions & 9 deletions client/conversation.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package client

import (
"context"
"fmt"
runtimev1pb "github.com/dapr/dapr/pkg/proto/runtime/v1"
"google.golang.org/protobuf/types/known/anypb"
)
Expand All @@ -36,12 +35,6 @@ type ConversationInput struct {
ScrubPII *bool // Scrub PII from the input
}

type ConversationInputOption func(*ConversationInput)

func NewConversationInput(message string, opts ...ConversationInputOption) ConversationInput {
return ConversationInput{}
}

type ConversationResponse struct {
ContextID string
Outputs []ConversationResult
Expand Down Expand Up @@ -110,8 +103,6 @@ func (c *GRPCClient) ConverseAlpha1(ctx context.Context, componentName string, i
Temperature: o.Temperature,
}

fmt.Println("invoking")

resp, err := c.protoClient.ConverseAlpha1(ctx, &request)
if err != nil {
return nil, err
Expand Down
36 changes: 36 additions & 0 deletions examples/conversation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Dapr Conversation Example with go-sdk

## Step

### Prepare

- Dapr installed

### Run Conversation Example

<!-- STEP
name: Run Conversation
output_match_mode: substring
expected_stdout_lines:
- '== APP == conversation output: hello world'
background: true
sleep: 60
timeout_seconds: 60
-->

```bash
dapr run --app-id conversation \
--dapr-grpc-port 50001 \
--log-level debug \
--resources-path ./config \
-- go run ./main.go
```

<!-- END_STEP -->

## Result

```
- '== APP == conversation output: hello world'
```
16 changes: 13 additions & 3 deletions examples/conversation/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,25 @@ import (
)

func main() {
client, err := dapr.NewClientWithPort("47649")
client, err := dapr.NewClient()
if err != nil {
panic(err)
}

resp, err := client.ConverseAlpha1(context.Background(), "echo", []dapr.ConversationInput{{Message: "hello"}})
input := dapr.ConversationInput{
Message: "hello world",
// Role: nil, // Optional
// ScrubPII: nil, // Optional
}

fmt.Printf("conversation input: %s\n", input.Message)

var conversationComponent = "echo"

resp, err := client.ConverseAlpha1(context.Background(), conversationComponent, []dapr.ConversationInput{input})
if err != nil {
log.Fatalf("err: %v", err)
}

fmt.Println(resp.Outputs)
fmt.Printf("conversation output: %s\n", resp.Outputs[0].Result)
}

0 comments on commit d4dda30

Please sign in to comment.