Documentation
¶
Index ¶
- Variables
- func DestroyEnvironment() error
- func InitializeEnvironment() error
- func InitializeGenAiLibrary() error
- func IsInitialized() bool
- func OgaResultToError(result *C.OgaResult) error
- func SetSharedLibraryPath(path string)
- type GenerationOptions
- type Guidance
- type GuidanceType
- type Images
- type MaxLengthReachedError
- type Message
- type NamedTensors
- type SequenceDelta
- type Session
- func (s *Session) Destroy()
- func (s *Session) Generate(ctx context.Context, messages [][]Message, tools []string, ...) (<-chan SequenceDelta, <-chan error, error)
- func (s *Session) GenerateWithImages(ctx context.Context, messages [][]Message, images *Images, tools []string, ...) (<-chan SequenceDelta, <-chan error, error)
- func (s *Session) GetStatistics() *Statistics
- type Statistics
Constants ¶
This section is empty.
Variables ¶
var ErrNotInitialized = fmt.Errorf("InitializeEnvironment() has either " +
"not yet been called, or did not return successfully")
Functions ¶
func DestroyEnvironment ¶
func DestroyEnvironment() error
DestroyEnvironment Call this function to clean up the internal onnxruntime environment when it is no longer required.
func InitializeEnvironment ¶
func InitializeEnvironment() error
func InitializeGenAiLibrary ¶
func InitializeGenAiLibrary() error
InitializeGenAiLibrary loads the ONNX Runtime GenAI shared library specified by onnxGenaiSharedLibraryPath (or a default) so its exported symbols become available. The assumption is that libonnxruntime.so is available in the same folder where the libonnxruntime-genai.so is located.
func IsInitialized ¶
func IsInitialized() bool
func OgaResultToError ¶
func SetSharedLibraryPath ¶
func SetSharedLibraryPath(path string)
Types ¶
type GenerationOptions ¶
type Guidance ¶ added in v0.2.0
type Guidance struct {
Type GuidanceType
Data string
// EnableFFTokens speeds up generation by force-forwarding tokens that satisfy the grammar
// without calling the model. Only valid when BatchSize=1 and beam_size=1.
EnableFFTokens bool
}
Guidance configures constrained (guided) generation. Requires a recent OGA runtime.
type GuidanceType ¶ added in v0.2.0
type GuidanceType string
GuidanceType specifies the constrained-generation strategy passed to OgaGeneratorParamsSetGuidance.
const ( GuidanceTypeJSONSchema GuidanceType = "json_schema" GuidanceTypeRegex GuidanceType = "regex" GuidanceTypeLarkGrammar GuidanceType = "lark_grammar" )
type Images ¶ added in v0.0.2
type Images struct {
// contains filtered or unexported fields
}
Images represents a collection of loaded images for multimodal processing.
func LoadImageFromBuffer ¶ added in v0.0.2
LoadImageFromBuffer loads a single image from a byte buffer.
func LoadImages ¶ added in v0.0.2
LoadImages loads multiple images from file paths or data URIs.
func LoadImagesFromBuffers ¶ added in v0.0.2
LoadImagesFromBuffers loads multiple images from byte buffers.
type MaxLengthReachedError ¶ added in v0.1.0
type MaxLengthReachedError struct{}
func (MaxLengthReachedError) Error ¶ added in v0.1.0
func (e MaxLengthReachedError) Error() string
type NamedTensors ¶ added in v0.0.2
type NamedTensors struct {
// contains filtered or unexported fields
}
NamedTensors represents a collection of named tensor inputs.
func (*NamedTensors) Destroy ¶ added in v0.0.2
func (nt *NamedTensors) Destroy()
Destroy releases the named tensors resources.
type SequenceDelta ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func CreateSession ¶ added in v0.1.0
func CreateSessionWithOptions ¶ added in v0.1.0
func CreateSessionWithOptions(configDirectoryPath string, providers []string, providerOptions map[string]map[string]string) (*Session, error)
CreateSessionWithOptions builds a GenAI config from a config directory, applies execution providers and options, creates the model and tokenizer, and returns a Session. providers: list of EP names in priority order (e.g., ["cuda"], ["NvTensorRtRtx"], ["OpenVINO"]). providerOptions: map of EP name -> map of key/value options.
func (*Session) Generate ¶
func (s *Session) Generate(ctx context.Context, messages [][]Message, tools []string, generationOptions *GenerationOptions) (<-chan SequenceDelta, <-chan error, error)
func (*Session) GenerateWithImages ¶ added in v0.0.2
func (s *Session) GenerateWithImages(ctx context.Context, messages [][]Message, images *Images, tools []string, generationOptions *GenerationOptions) (<-chan SequenceDelta, <-chan error, error)
GenerateWithImages generates text using pre-processed named tensors (for multimodal inputs). Currently only supports a single prompt.
func (*Session) GetStatistics ¶
func (s *Session) GetStatistics() *Statistics
GetStatistics returns the last computed statistics for the session.