Documentation
¶
Index ¶
- Constants
- func BAMLTESTINGONLY_InternalEncode(value any) (*cffi.HostValue, error)
- func Decode(holder *cffi.CFFIValueHolder) reflect.Value
- func EncodeClass(name string, fields map[string]any, dynamicFields *map[string]any) (*cffi.HostValue, error)
- func EncodeEnum(name string, value string, is_dynamic bool) (*cffi.HostValue, error)
- func EncodeValue(value any) (*cffi.HostValue, error)
- func InvokeRuntimeCli(args []string) int
- func SetTypeMap(t serde.TypeMap)
- type ASTNodeSource
- type Audio
- type BamlClientError
- type BamlClientHttpError
- type BamlError
- type BamlFunctionArguments
- type BamlRuntime
- func (r *BamlRuntime) CallFunction(ctx context.Context, functionName string, encoded_args []byte, ...) (*ResultCallback, error)
- func (r *BamlRuntime) CallFunctionParse(ctx context.Context, functionName string, encoded_args []byte) (any, error)
- func (r *BamlRuntime) CallFunctionStream(ctx context.Context, functionName string, encoded_args []byte, ...) (<-chan ResultCallback, error)
- func (r *BamlRuntime) NewAudioFromBase64(base64 string, mimeType *string) (Audio, error)
- func (r *BamlRuntime) NewAudioFromUrl(url string, mimeType *string) (Audio, error)
- func (r *BamlRuntime) NewCollector(name string) (Collector, error)
- func (r *BamlRuntime) NewImageFromBase64(base64 string, mimeType *string) (Image, error)
- func (r *BamlRuntime) NewImageFromUrl(url string, mimeType *string) (Image, error)
- func (r *BamlRuntime) NewPDFFromBase64(base64 string, mimeType *string) (PDF, error)
- func (r *BamlRuntime) NewPDFFromUrl(url string, mimeType *string) (PDF, error)
- func (r *BamlRuntime) NewTypeBuilder() (TypeBuilder, error)
- func (r *BamlRuntime) NewVideoFromBase64(base64 string, mimeType *string) (Video, error)
- func (r *BamlRuntime) NewVideoFromUrl(url string, mimeType *string) (Video, error)
- type CallbackData
- type Checked
- type ClassBuilder
- type ClassPropertyBuilder
- type ClientRegistry
- type Collector
- type EnumBuilder
- type EnumValueBuilder
- type FunctionLog
- type FunctionSignal
- type HTTPBody
- type HTTPRequest
- type HTTPResponse
- type Image
- type LLMCall
- type LLMStreamCall
- type MediaType
- type OnTickCallbackData
- type PDF
- type ResultCallback
- type SSEResponse
- type StreamResult
- type StreamState
- type StreamTiming
- type StreamingStateType
- type TickCallback
- type TickReason
- type Timing
- type Type
- type TypeBuilder
- type TypeMap
- type Usage
- type Video
Constants ¶
View Source
const ( StreamStatePending = shared.StreamStatePending StreamStateIncomplete = shared.StreamStateIncomplete StreamStateComplete = shared.StreamStateComplete )
Variables ¶
This section is empty.
Functions ¶
func BAMLTESTINGONLY_InternalEncode ¶ added in v0.201.0
func EncodeClass ¶
func EncodeEnum ¶
func InvokeRuntimeCli ¶
func SetTypeMap ¶
Types ¶
type ASTNodeSource ¶ added in v0.204.0
type ASTNodeSource string
const ( ASTNodeSource_Unknown ASTNodeSource = "unknown" ASTNodeSource_Baml ASTNodeSource = "baml_file" ASTNodeSource_TypeBuilder ASTNodeSource = "type_builder" )
type BamlClientError ¶
type BamlClientError struct {
BamlError
}
type BamlClientHttpError ¶
type BamlClientHttpError struct {
BamlClientError
}
type BamlFunctionArguments ¶ added in v0.86.1
type BamlFunctionArguments struct {
Kwargs map[string]any
ClientRegistry *ClientRegistry
Env map[string]string
Collectors []Collector
TypeBuilder TypeBuilder
Tags map[string]string
}
func (*BamlFunctionArguments) Encode ¶ added in v0.202.0
func (args *BamlFunctionArguments) Encode() ([]byte, error)
type BamlRuntime ¶
type BamlRuntime struct {
// contains filtered or unexported fields
}
func CreateRuntime ¶
func (*BamlRuntime) CallFunction ¶
func (r *BamlRuntime) CallFunction(ctx context.Context, functionName string, encoded_args []byte, onTick OnTickCallbackData) (*ResultCallback, error)
func (*BamlRuntime) CallFunctionParse ¶ added in v0.204.0
func (*BamlRuntime) CallFunctionStream ¶
func (r *BamlRuntime) CallFunctionStream(ctx context.Context, functionName string, encoded_args []byte, onTick OnTickCallbackData) (<-chan ResultCallback, error)
func (*BamlRuntime) NewAudioFromBase64 ¶ added in v0.203.0
func (r *BamlRuntime) NewAudioFromBase64(base64 string, mimeType *string) (Audio, error)
func (*BamlRuntime) NewAudioFromUrl ¶ added in v0.203.0
func (r *BamlRuntime) NewAudioFromUrl(url string, mimeType *string) (Audio, error)
func (*BamlRuntime) NewCollector ¶ added in v0.203.0
func (r *BamlRuntime) NewCollector(name string) (Collector, error)
/ Construct Collector
func (*BamlRuntime) NewImageFromBase64 ¶ added in v0.203.0
func (r *BamlRuntime) NewImageFromBase64(base64 string, mimeType *string) (Image, error)
func (*BamlRuntime) NewImageFromUrl ¶ added in v0.203.0
func (r *BamlRuntime) NewImageFromUrl(url string, mimeType *string) (Image, error)
func (*BamlRuntime) NewPDFFromBase64 ¶ added in v0.203.0
func (r *BamlRuntime) NewPDFFromBase64(base64 string, mimeType *string) (PDF, error)
func (*BamlRuntime) NewPDFFromUrl ¶ added in v0.203.0
func (r *BamlRuntime) NewPDFFromUrl(url string, mimeType *string) (PDF, error)
func (*BamlRuntime) NewTypeBuilder ¶ added in v0.204.0
func (r *BamlRuntime) NewTypeBuilder() (TypeBuilder, error)
func (*BamlRuntime) NewVideoFromBase64 ¶ added in v0.203.0
func (r *BamlRuntime) NewVideoFromBase64(base64 string, mimeType *string) (Video, error)
func (*BamlRuntime) NewVideoFromUrl ¶ added in v0.203.0
func (r *BamlRuntime) NewVideoFromUrl(url string, mimeType *string) (Video, error)
type CallbackData ¶
type CallbackData struct {
// contains filtered or unexported fields
}
type ClassBuilder ¶ added in v0.204.0
type ClassBuilder interface {
raw_objects.RawPointer
// Get the type definition for this class
Type() (Type, error)
// List all properties in the class
ListProperties() ([]ClassPropertyBuilder, error)
// Add a new property to the class
AddProperty(name string, fieldType Type) (ClassPropertyBuilder, error)
// Get a specific property from the class
Property(name string) (ClassPropertyBuilder, error)
// contains filtered or unexported methods
}
type ClassPropertyBuilder ¶ added in v0.204.0
type ClassPropertyBuilder interface {
raw_objects.RawPointer
// Set the type for the property
SetType(fieldType Type) error
// Get the type for the property
Type() (Type, error)
// contains filtered or unexported methods
}
type ClientRegistry ¶ added in v0.89.0
type ClientRegistry struct {
// contains filtered or unexported fields
}
func NewClientRegistry ¶ added in v0.89.0
func NewClientRegistry() *ClientRegistry
func (*ClientRegistry) AddLlmClient ¶ added in v0.89.0
func (c *ClientRegistry) AddLlmClient(name string, provider string, options map[string]any)
func (*ClientRegistry) SetPrimaryClient ¶ added in v0.89.0
func (c *ClientRegistry) SetPrimaryClient(name string)
type Collector ¶ added in v0.200.0
type Collector interface {
raw_objects.RawPointer
// Usage gathers the Usage object but keeps the underlying C collector alive
// until the Usage is done.
Usage() (Usage, error)
// Name returns the collector name
Name() (string, error)
// Logs returns all function logs
Logs() ([]FunctionLog, error)
// Last returns the most recent function log
Last() (FunctionLog, error)
// ID looks up a function log by ID
Id(functionId string) (FunctionLog, error)
// Clear removes all logs and frees memory
Clear() (int64, error)
}
type EnumBuilder ¶ added in v0.204.0
type EnumBuilder interface {
raw_objects.RawPointer
// Add a new value to the enum
AddValue(value string) (EnumValueBuilder, error)
// Get the type definition for this enum
Type() (Type, error)
// List all values in the enum
ListValues() ([]EnumValueBuilder, error)
// Get a specific value from the enum
Value(name string) (EnumValueBuilder, error)
// contains filtered or unexported methods
}
type EnumValueBuilder ¶ added in v0.204.0
type EnumValueBuilder interface {
raw_objects.RawPointer
// Mark the enum value to be skipped
SetSkip(skip bool) error
// Get the skip value
Skip() (bool, error)
// contains filtered or unexported methods
}
type FunctionLog ¶ added in v0.202.0
type FunctionLog interface {
raw_objects.RawPointer
// ID returns the function log ID
Id() (string, error)
// FunctionName returns the function name
FunctionName() (string, error)
// LogType returns the log type
LogType() (string, error)
// Timing returns the timing information
Timing() (Timing, error)
// Usage returns the usage information
Usage() (Usage, error)
// RawLLMResponse returns the raw LLM response
RawLLMResponse() (string, error)
// Calls returns all LLM calls made during this function execution (can be LLMCall or LLMStreamCall)
Calls() ([]LLMCall, error)
// SelectedCall returns the call that was selected for parsing (can be LLMCall or LLMStreamCall)
SelectedCall() (LLMCall, error)
// Tags returns any user-provided metadata
Tags() (map[string]any, error)
}
type FunctionSignal ¶ added in v0.202.0
type FunctionSignal interface{}
type HTTPBody ¶ added in v0.202.0
type HTTPBody interface {
raw_objects.RawPointer
// Text returns the body as a string
Text() (string, error)
// JSON returns the body as a JSON object
JSON() (any, error)
}
type HTTPRequest ¶ added in v0.202.0
type HTTPRequest interface {
raw_objects.RawPointer
// ID returns the request ID
RequestId() (string, error)
// URL returns the request URL
Url() (string, error)
// Method returns the HTTP method
Method() (string, error)
// Headers returns the request headers
Headers() (map[string]string, error)
// Body returns the request body
Body() (HTTPBody, error)
}
type HTTPResponse ¶ added in v0.202.0
type HTTPResponse interface {
raw_objects.RawPointer
// ID returns the request ID
RequestId() (string, error)
// Status returns the HTTP status code
Status() (int64, error)
// Headers returns the response headers
Headers() (map[string]string, error)
// Body returns the response body
Body() (HTTPBody, error)
}
type LLMCall ¶ added in v0.202.0
type LLMCall interface {
raw_objects.RawPointer
// ID returns the request ID: Not the same as the function log ID
RequestId() (string, error)
// ClientName returns the name of the client used
ClientName() (string, error)
// Provider returns the provider of the client
Provider() (string, error)
// HttpRequest returns the raw HTTP request
HttpRequest() (HTTPRequest, error)
// HttpResponse returns the raw HTTP response (nullable for streaming)
HttpResponse() (HTTPResponse, error)
// Usage returns the usage information (nullable)
Usage() (Usage, error)
// Selected returns whether this call was selected for parsing
Selected() (bool, error)
// Timing returns the timing information
Timing() (Timing, error)
}
type LLMStreamCall ¶ added in v0.202.0
type LLMStreamCall interface {
LLMCall
// SSEChunks returns the SSE chunks of the response
SSEChunks() ([]SSEResponse, error)
}
type OnTickCallbackData ¶ added in v0.202.0
type OnTickCallbackData interface {
Collector() Collector
OnTick() TickCallback
}
type ResultCallback ¶
type SSEResponse ¶ added in v0.202.0
type SSEResponse interface {
raw_objects.RawPointer
// Text returns the body as a string
Text() (string, error)
// JSON returns the body as a JSON object (nullable)
JSON() (any, error)
}
type StreamResult ¶
func (*StreamResult[Partial, Final]) Error ¶
func (result *StreamResult[Partial, Final]) Error() error
func (*StreamResult[Partial, Final]) Final ¶
func (result *StreamResult[Partial, Final]) Final() Final
func (*StreamResult[Partial, Final]) IsFinal ¶
func (result *StreamResult[Partial, Final]) IsFinal() bool
func (*StreamResult[Partial, Final]) IsPartial ¶
func (result *StreamResult[Partial, Final]) IsPartial() bool
func (*StreamResult[Partial, Final]) Partial ¶
func (result *StreamResult[Partial, Final]) Partial() Partial
type StreamState ¶
type StreamState[T any] = shared.StreamState[T]
type StreamTiming ¶ added in v0.202.0
type StreamTiming interface {
Timing
}
type StreamingStateType ¶ added in v0.202.0
type StreamingStateType = shared.StreamStateType
type TickCallback ¶ added in v0.202.0
type TickCallback func(ctx context.Context, reason TickReason, log FunctionLog) FunctionSignal
type TickReason ¶ added in v0.202.0
type TickReason string
const (
TickReason_Unknown TickReason = "Unknown"
)
type Timing ¶ added in v0.202.0
type Timing interface {
raw_objects.RawPointer
// StartTimeUTCMs returns the start time in milliseconds since epoch
StartTimeUTCMs() (int64, error)
// DurationMs returns the duration in milliseconds (nullable)
DurationMs() (*int64, error)
}
type Type ¶ added in v0.204.0
type Type interface {
raw_objects.RawPointer
serde.InternalBamlSerializer
// Type extensions
List() (Type, error)
Optional() (Type, error)
Print() string
}
type TypeBuilder ¶ added in v0.204.0
type TypeBuilder interface {
raw_objects.RawPointer
// Basic types
String() (Type, error)
Int() (Type, error)
Float() (Type, error)
Bool() (Type, error)
Null() (Type, error)
// Literal types
LiteralString(value string) (Type, error)
LiteralInt(value int64) (Type, error)
LiteralBool(value bool) (Type, error)
// Composite types
Map(key Type, value Type) (Type, error)
List(inner Type) (Type, error)
Optional(inner Type) (Type, error)
Union(types []Type) (Type, error)
// BAML schema operations
AddBaml(baml string) error
// Enum operations
AddEnum(name string) (EnumBuilder, error)
Enum(name string) (EnumBuilder, error)
ListEnums() ([]EnumBuilder, error)
// Class operations
AddClass(name string) (ClassBuilder, error)
Class(name string) (ClassBuilder, error)
ListClasses() ([]ClassBuilder, error)
// Display the type builder
Print() string
}
type Usage ¶ added in v0.200.0
type Usage interface {
raw_objects.RawPointer
// InputTokens returns the number of input tokens
InputTokens() (int64, error)
// OutputTokens returns the number of output tokens
OutputTokens() (int64, error)
// CachedInputTokens returns the number of cached input tokens
CachedInputTokens() (int64, error)
}
Source Files
¶
- callbacks.go
- lib.go
- rawobjects_class_builder.go
- rawobjects_class_property_builder.go
- rawobjects_client_registry.go
- rawobjects_collector.go
- rawobjects_constructors.go
- rawobjects_enum_builder.go
- rawobjects_enum_value_builder.go
- rawobjects_function_args.go
- rawobjects_function_log.go
- rawobjects_http_body.go
- rawobjects_http_request.go
- rawobjects_http_response.go
- rawobjects_llm_call.go
- rawobjects_llm_stream_call.go
- rawobjects_llmrenderable.go
- rawobjects_media.go
- rawobjects_public.go
- rawobjects_sse_response.go
- rawobjects_stream_timing.go
- rawobjects_tick_callback.go
- rawobjects_timing.go
- rawobjects_type_builder.go
- rawobjects_type_def.go
- rawobjects_usage.go
- rawobjects_utils.go
- runtime.go
- stream_result.go
Click to show internal directories.
Click to hide internal directories.