models

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

The models package provides a generic interface for invoking various AI models.

Index

Constants

View Source
const MockResponseText = "Hello, World!"

Variables

View Source
var InvokeModelCallStack = testutils.NewCallStack()
View Source
var LookupModelCallStack = testutils.NewCallStack()

Functions

func GetModel

func GetModel[TModel Model[TIn, TOut], TIn, TOut any, P modelPtr[TModel]](name string) (*TModel, error)

Gets a model object instance, which can be used to interact with the model.

  • The generic type parameter [TModel] is used to specify the API that the model adheres to.
  • The name parameter is used to identify the model in the modus.json manifest file.

Note that of the generic type parameters, only [TModel] needs to be specified. The others are inferred automatically.

Types

type Model

type Model[TIn, TOut any] interface {
	Info() *ModelInfo
	Invoke(input *TIn) (*TOut, error)
}

Provides a generic interface for interacting with an AI model.

type ModelBase

type ModelBase[TIn, TOut any] struct {
	Debug bool
	// contains filtered or unexported fields
}

Provides a base implementation for all models.

func (ModelBase[TIn, TOut]) Info

func (m ModelBase[TIn, TOut]) Info() *ModelInfo

Gets the model information.

func (ModelBase[TIn, TOut]) Invoke

func (m ModelBase[TIn, TOut]) Invoke(input *TIn) (*TOut, error)

Invokes the model with the specified input and returns the output generated by the model.

type ModelInfo

type ModelInfo struct {

	// The name of the model, as specified in the modus.json manifest file.
	Name string

	// The full name of the model that the provider uses to identify the model.
	FullName string
}

Provides information about a model.

Directories

Path Synopsis
The openai package provides objects that conform to the OpenAI API specification.
The openai package provides objects that conform to the OpenAI API specification.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL