Client-side logic for streaming messages to and from micro-agents. Use this to facilitate real-time conversational interfaces between users and backend agent services.
// Source: https://github.com/micro/go-micro | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
package chat
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"go-micro.dev/v6/agent"
pb "go-micro.dev/v6/agent/proto"
"go-micro.dev/v6/client"
"go-micro.dev/v6/model"
)
func (s *session) interactAgent(ctx context.Context, name, message string) error {
ctx, cancel := context.WithCancelCause(ctx)
defer cancel(nil)
stream, err := pb.NewAgentInteractionService(name, s.cl).Chat(ctx, client.WithRetries(0))
if err != nil {
return err
}
defer stream.Close()
if err := stream.Send(&pb.InteractionRequest{Message: message}); err != nil {
return err
}
if s.display != nil
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key