Documentation
¶
Index ¶
- Constants
- func Decode(holder *cffi.CFFIValueHolder) reflect.Value
- func DecodeStreamingState[T any](holder *cffi.CFFIValueHolder, decodeFunc func(inner *cffi.CFFIValueHolder) T) shared.StreamState[T]
- func EncodeClass(name func() *cffi.CFFITypeName, fields map[string]any, ...) (*cffi.CFFIValueHolder, error)
- func EncodeEnum(name func() *cffi.CFFITypeName, value string, is_dynamic bool) (*cffi.CFFIValueHolder, error)
- func EncodeUnion(name func() *cffi.CFFITypeName, variant string, value any) (*cffi.CFFIValueHolder, error)
- func InvokeRuntimeCli(args []string) int
- func SetTypeMap(t serde.TypeMap)
- 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) 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) NewVideoFromBase64(base64 string, mimeType *string) (Video, error)
- func (r *BamlRuntime) NewVideoFromUrl(url string, mimeType *string) (Video, error)
- type CallbackData
- type Checked
- type ClientRegistry
- type Collector
- 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 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 DecodeStreamingState ¶ added in v0.200.0
func DecodeStreamingState[T any](holder *cffi.CFFIValueHolder, decodeFunc func(inner *cffi.CFFIValueHolder) T) shared.StreamState[T]
func EncodeClass ¶
func EncodeClass(name func() *cffi.CFFITypeName, fields map[string]any, dynamicFields *map[string]any) (*cffi.CFFIValueHolder, error)
func EncodeEnum ¶
func EncodeEnum(name func() *cffi.CFFITypeName, value string, is_dynamic bool) (*cffi.CFFIValueHolder, error)
func EncodeUnion ¶
func EncodeUnion(name func() *cffi.CFFITypeName, variant string, value any) (*cffi.CFFIValueHolder, error)
func InvokeRuntimeCli ¶
func SetTypeMap ¶
Types ¶
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
}
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) 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) 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 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 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 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)
}
Source Files
¶
- callbacks.go
- lib.go
- rawobjects_client_registry.go
- rawobjects_collector.go
- rawobjects_constructors.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_media.go
- rawobjects_public.go
- rawobjects_sse_response.go
- rawobjects_stream_timing.go
- rawobjects_tick_callback.go
- rawobjects_timing.go
- rawobjects_usage.go
- rawobjects_utils.go
- runtime.go
- stream_result.go
Click to show internal directories.
Click to hide internal directories.