mirror of https://github.com/dapr/go-sdk.git
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
/*
|
|
Copyright 2024 The Dapr Authors
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
|
|
dapr "github.com/dapr/go-sdk/client"
|
|
)
|
|
|
|
func main() {
|
|
client, err := dapr.NewClient()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
input := dapr.ConversationInput{
|
|
Content: "hello world",
|
|
// Role: nil, // Optional
|
|
// ScrubPII: nil, // Optional
|
|
}
|
|
|
|
fmt.Printf("conversation input: %s\n", input.Content)
|
|
|
|
var conversationComponent = "echo"
|
|
|
|
request := dapr.NewConversationRequest(conversationComponent, []dapr.ConversationInput{input})
|
|
|
|
resp, err := client.ConverseAlpha1(context.Background(), request)
|
|
if err != nil {
|
|
log.Fatalf("err: %v", err)
|
|
}
|
|
|
|
fmt.Printf("conversation output: %s\n", resp.Outputs[0].Result)
|
|
}
|