Documentation ¶
Index ¶
- Constants
- Variables
- func HandshakeConfig() plugin.HandshakeConfig
- func InitLogging(ctx context.Context, name string) context.Context
- func Plugins() map[string]plugin.Plugin
- func Version() string
- type Completion
- type CompletionGRPCClient
- type CompletionGRPCServer
- type Embedding
- type EmbeddingGRPCClient
- type EmbeddingGRPCServer
- type Interfaces
- type InterfacesGRPCClient
- type InterfacesGRPCServer
- type Memory
- type MemoryGRPCClient
- type MemoryGRPCServer
- type Message
- type Plugin
- func (plugin *Plugin) Client(_ *plugin.MuxBroker, _ *rpc.Client) (interface{}, error)
- func (plugin *Plugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, client *grpc.ClientConn) (interface{}, error)
- func (plugin *Plugin) GRPCServer(_ *plugin.GRPCBroker, srv *grpc.Server) error
- func (plugin *Plugin) Server(_ *plugin.MuxBroker) (interface{}, error)
Constants ¶
const ( VersionMajor = 1 VersionMinor = 0 ProtocolVersion = VersionMajor MagicCookieKey = "LAZYGPT_PLUGIN_MAGIC_COOKIE" MagicCookieValue = "678363c73a70838a84ea7f90a1c7bdfc6e80e8560e50ea75e0a6ca906d00c881" )
Variables ¶
var ErrNotGRPC = errors.New("only gRPC plugins supported")
ErrNotGRPC is returned when a plugin is not a gRPC plugin.
Functions ¶
func HandshakeConfig ¶
func HandshakeConfig() plugin.HandshakeConfig
HandshakeConfig returns a plugin.HandshakeConfig with the proper magic cookie values to use for this protocol version.
func InitLogging ¶
InitLogging initializes a logger in the context.
Types ¶
type Completion ¶
type Completion interface { // Complete returns a list of possible completions for the given input. Complete(ctx context.Context, messages []Message) (*Message, Reason, error) }
Completion is the interface that plugins must implement to provide completion suggestions.
type CompletionGRPCClient ¶
type CompletionGRPCClient struct {
Client CompletionClient
}
CompletionGRPCClient is the gRPC client implementation of the plugin.
func NewCompletionGRPCClient ¶
func NewCompletionGRPCClient(client CompletionClient) *CompletionGRPCClient
NewCompletionGRPCClient returns a new CompletionGRPCClient.
type CompletionGRPCServer ¶
type CompletionGRPCServer struct { UnimplementedCompletionServer Impl Completion }
CompletionGRPCServer is the gRPC server implementation of the plugin.
func NewCompletionGRPCServer ¶
func NewCompletionGRPCServer(impl Completion) *CompletionGRPCServer
NewCompletionGRPCServer returns a new CompletionGRPCServer.
type Embedding ¶
type Embedding interface { // Embedding returns the embedding for the given input. Embedding(ctx context.Context, input string) ([]float32, error) }
Embedding is the interface that plugins must implement to provide embedding functionality.
type EmbeddingGRPCClient ¶
type EmbeddingGRPCClient struct {
Client EmbeddingClient
}
EmbeddingGRPCClient is the gRPC client implementation of the plugin.
func NewEmbeddingGRPCClient ¶
func NewEmbeddingGRPCClient(client EmbeddingClient) *EmbeddingGRPCClient
NewEmbeddingGRPCClient returns a new EmbeddingGRPCClient.
type EmbeddingGRPCServer ¶
type EmbeddingGRPCServer struct { UnimplementedEmbeddingServer Impl Embedding }
EmbeddingGRPCServer is the gRPC server implementation of the plugin.
func NewEmbeddingGRPCServer ¶
func NewEmbeddingGRPCServer(impl Embedding) *EmbeddingGRPCServer
NewEmbeddingGRPCServer returns a new EmbeddingGRPCServer.
type Interfaces ¶
type Interfaces interface { // Interfaces returns a list of interfaces that the plugin implements. Interfaces(ctx context.Context) ([]string, error) }
Interfaces is the interface that plugins must implement to provide discovery of implemented interfaces.
type InterfacesGRPCClient ¶
type InterfacesGRPCClient struct {
Client InterfacesClient
}
InterfacesGRPCClient is the gRPC client implementation of the plugin.
func NewInterfacesGRPCClient ¶
func NewInterfacesGRPCClient(client InterfacesClient) *InterfacesGRPCClient
NewInterfacesGRPCClient returns a new InterfacesGRPCClient.
func (*InterfacesGRPCClient) Interfaces ¶
func (c *InterfacesGRPCClient) Interfaces(ctx context.Context) ([]string, error)
Interfaces implements the gRPC client for the interfaces plugin.
type InterfacesGRPCServer ¶
type InterfacesGRPCServer struct { UnimplementedInterfacesServer Impl Interfaces }
InterfacesGRPCServer is the gRPC server implementation of the plugin.
func NewInterfacesGRPCServer ¶
func NewInterfacesGRPCServer(impl Interfaces) *InterfacesGRPCServer
NewInterfacesGRPCServer returns a new InterfacesGRPCServer.
func (*InterfacesGRPCServer) Interfaces ¶
func (s *InterfacesGRPCServer) Interfaces( ctx context.Context, _ *InterfacesRequest, ) (*InterfacesResponse, error)
Interfaces implements the gRPC server for the interfaces plugin.
type Memory ¶
type Memory interface { // Memorize memorizes each data string. Memorize(ctx context.Context, data []string) error // Recall recalls the memory closest to the data string. If a count is // specified, it returns the count closest memories. Recall(ctx context.Context, data string, count ...int) ([]string, error) }
Memory is the interface that plugins must implement to provide memory functionality.
type MemoryGRPCClient ¶
type MemoryGRPCClient struct {
Client MemoryClient
}
MemoryGRPCClient is the gRPC client implementation of the plugin.
func NewMemoryGRPCClient ¶
func NewMemoryGRPCClient(client MemoryClient) *MemoryGRPCClient
NewMemoryGRPCClient returns a new MemoryGRPCClient.
type MemoryGRPCServer ¶
type MemoryGRPCServer struct { UnimplementedMemoryServer Impl Memory }
MemoryGRPCServer is the gRPC server implementation of the plugin.
func NewMemoryGRPCServer ¶
func NewMemoryGRPCServer(impl Memory) *MemoryGRPCServer
NewMemoryGRPCServer returns a new MemoryGRPCServer.
type Plugin ¶
type Plugin struct { plugin.Plugin // contains filtered or unexported fields }
func NewCompletionPlugin ¶
func NewCompletionPlugin(completion Completion) *Plugin
NewCompletionPlugin returns a new CompletionPlugin.
func NewEmbeddingPlugin ¶
NewEmbeddingPlugin returns a new EmbeddingPlugin.
func NewInterfacesPlugin ¶
func NewInterfacesPlugin(interfaces Interfaces) *Plugin
NewInterfacesPlugin returns a new InterfacesPlugin.
func NewMemoryPlugin ¶
NewMemoryPlugin returns a new MemoryPlugin.
func NewPlugin ¶
func NewPlugin( register func(*grpc.Server), client func(*grpc.ClientConn) (interface{}, error), ) *Plugin
NewPlugin return a new plugin instance for the given plugin implementation.
func (*Plugin) GRPCClient ¶
func (plugin *Plugin) GRPCClient( _ context.Context, _ *plugin.GRPCBroker, client *grpc.ClientConn, ) (interface{}, error)
GRPCClient returns the plugin client.
func (*Plugin) GRPCServer ¶
GRPCServer registers the plugin with the gRPC server.