Documentation
¶
Index ¶
- Constants
- func CreateDiscoveryTool(request *CreateDiscoveryToolRequest) *aipb.Tool
- func MessageToolRequest(message proto.Message, options ...Option) *pb.CreateToolRequest
- func MethodToolRequest(method Method, options ...Option) *pb.CreateToolRequest
- func NewSchemaConfiguration(options ...Option) *pb.SchemaConfiguration
- func ParseDiscoveryToolCall(toolCall *aipb.ToolCall) (*aipb.ToolCallDiscovery, error)
- func ParseToolCall(schema *pbjson.SchemaBuilder, toolCall *aipb.ToolCall, ...) (*pb.ParseToolCallResponse, error)
- func ParseToolCallMessage(schemaBuilder *pbjson.SchemaBuilder, toolCall *aipb.ToolCall) (*structpb.Struct, error)
- type CreateDiscoveryToolRequest
- type Method
- type Option
Constants ¶
const ( // Namespace prefix for all AI engine annotations. AnnotationKeyPrefix = "ai-engine.malonaz.com/" // The fully qualified gRPC service name that backs this tool. AnnotationKeyGRPCService = AnnotationKeyPrefix + "grpc-service" // The fully qualified gRPC method name that backs this tool. AnnotationKeyGRPCMethod = AnnotationKeyPrefix + "grpc-method" // The fully qualified protobuf message name used as the tool's input/output schema. AnnotationKeyProtoMessage = AnnotationKeyPrefix + "proto-message" // The type of tool: discovery, generate-message, or generate-rpc-request. AnnotationKeyToolType = AnnotationKeyPrefix + "tool-type" // When "true", indicates the tool has no side effects (safe to call speculatively). AnnotationKeyNoSideEffect = AnnotationKeyPrefix + "no-side-effect" // A comma-separated field mask applied to the generated message to restrict which fields are populated. AnnotationKeyGenerationFieldMask = AnnotationKeyPrefix + "generation-field-mask" // When present, indicates the tool was registered via a discovery tool set and must be discovered before use. AnnotationKeyDiscoverableTool = AnnotationKeyPrefix + "discoverable-tool" // The name of the tool set this tool belongs to, used to resolve discovery tool calls. AnnotationKeyToolSetName = AnnotationKeyPrefix + "tool-set-name" // When "true", indicates this tool is pre-discovered and available without requiring a discovery tool call. AnnotationKeyPreDiscoveredTool = AnnotationKeyPrefix + "pre-discovered-tool" // The comma-separated list of tool names returned by a discovery tool call. AnnotationKeyDiscoveredTools = AnnotationKeyPrefix + "discovered-tools" // Tool type indicating a discovery tool that reveals other tools to the model. AnnotationValueToolTypeDiscovery = "discovery" // Tool type indicating the tool generates a standalone protobuf message. AnnotationValueToolTypeGenerateMessage = "generate-message" // Tool type indicating the tool generates a gRPC request to be dispatched. AnnotationValueToolTypeGenerateRPCRequest = "generate-rpc-request" )
Variables ¶
This section is empty.
Functions ¶
func CreateDiscoveryTool ¶
func CreateDiscoveryTool(request *CreateDiscoveryToolRequest) *aipb.Tool
func MessageToolRequest ¶
func MessageToolRequest(message proto.Message, options ...Option) *pb.CreateToolRequest
MessageToolRequest builds a CreateToolRequest whose schema mirrors the given message, so the resulting tool call parses straight back into it.
func MethodToolRequest ¶
func MethodToolRequest(method Method, options ...Option) *pb.CreateToolRequest
MethodToolRequest builds a CreateToolRequest whose schema mirrors the given method's request message.
func NewSchemaConfiguration ¶
func NewSchemaConfiguration(options ...Option) *pb.SchemaConfiguration
NewSchemaConfiguration builds a schema configuration from options, for the APIs that take one directly (e.g. CreateServiceToolSet).
func ParseDiscoveryToolCall ¶
func ParseDiscoveryToolCall(toolCall *aipb.ToolCall) (*aipb.ToolCallDiscovery, error)
func ParseToolCall ¶
func ParseToolCall(schema *pbjson.SchemaBuilder, toolCall *aipb.ToolCall, toolSets []*aipb.ToolSet) (*pb.ParseToolCallResponse, error)
func ParseToolCallMessage ¶
Types ¶
type Method ¶
type Method struct {
// contains filtered or unexported fields
}
Method identifies a gRPC method to build a tool from.
func NewMethod ¶
NewMethod accepts a generated gRPC full method name, e.g. userservicepb.UserService_CreateContact_FullMethodName.
gRPC spells these "/package.Service/Method", while protobuf descriptor lookups use the dotted "package.Service.Method" form.
func (Method) FullName ¶
FullName returns the dotted "package.Service.Method" form. This is what ToolCallRpc.method_full_name carries, and what the middleware matches on (it resolves gRPC's slashed name to a descriptor before comparing), so the same value serves both tool dispatch and hook registration.
type Option ¶
type Option func(*pb.SchemaConfiguration)
Option configures the schema derived from a descriptor.
func WithFieldMask ¶
func WithFieldMask(fieldMask *pbfieldmask.FieldMask) Option
WithFieldMask restricts the tool schema to the masked fields.
func WithMaxDepth ¶
WithMaxDepth bounds how deep the schema recurses. Left unset, the server applies its own default rather than us forking that policy client-side.
func WithResponseReadMask ¶
func WithResponseReadMask() Option
WithResponseReadMask lets the model request only the response fields it needs. Method tools only.
func WithResponseSchema ¶
WithResponseSchema includes the response schema in the tool description, bounded by maxDepth. Verbose, so use with care. Method tools only.
func WithSummary ¶
WithSummary injects a required summary field, documented with the given string: a human-readable account of the call for approval surfaces that never show raw arguments or resource names.