ai

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: MPL-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainParams

type ChainParams struct {
	Format string
	Steps  []ChainParamsStep
}

type ChainParamsStep

type ChainParamsStep struct {
	Input       string
	Instruction string
	Options     any
}

type ChainResult

type ChainResult struct {
	Text string
	Json map[string]any
}

type Config

type Config struct {
	OpenAIApiKey string

	AzureOpenAIApiKey                string
	AzureOpenAIEndpoint              string
	AzureOpenAIGptDeploymentID       string
	AzureOpenAIEmbeddingDeploymentID string

	Provider string

	Debug bool
}

type GeneralChatCompletionMessage

type GeneralChatCompletionMessage struct {
	Role    string
	Content string
}

func (GeneralChatCompletionMessage) Pretty

type Instant

type Instant struct {
	// contains filtered or unexported fields
}

func New

func New(cfg Config) *Instant

func (*Instant) CallInChain

func (s *Instant) CallInChain(ctx context.Context, params ChainParams) (*ChainResult, error)

func (*Instant) CreateEmbeddingAzureOpenAI

func (s *Instant) CreateEmbeddingAzureOpenAI(ctx context.Context, input []string) ([]float32, error)

func (*Instant) GetEmbeddings

func (s *Instant) GetEmbeddings(ctx context.Context, input []string) ([]float32, error)

func (*Instant) GrabJsonOutput

func (s *Instant) GrabJsonOutput(ctx context.Context, input string, outputKeys ...string) (map[string]any, error)

func (*Instant) MultipleSteps

func (s *Instant) MultipleSteps(ctx context.Context, params ChainParams) (*ChainResult, error)

func (*Instant) OneTimeRequest

func (s *Instant) OneTimeRequest(ctx context.Context, content string) (string, error)

func (*Instant) OneTimeRequestJson

func (s *Instant) OneTimeRequestJson(ctx context.Context, content string) (map[string]any, error)

func (*Instant) RawRequest

func (s *Instant) RawRequest(ctx context.Context, messages []GeneralChatCompletionMessage) (string, error)

func (*Instant) RawRequestAzureOpenAI

func (s *Instant) RawRequestAzureOpenAI(ctx context.Context, messages []azopenai.ChatRequestMessageClassification) (string, error)

func (*Instant) RawRequestOpenAI

func (s *Instant) RawRequestOpenAI(ctx context.Context, messages []openai.ChatCompletionMessage) (string, error)

func (*Instant) TwoSteps

func (s *Instant) TwoSteps(ctx context.Context, outputFormat string, input, inst string) (*ChainResult, error)

Jump to

Keyboard shortcuts

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