ai

package
v0.5.9-alpha.7 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AzureProvider       = "azureopenai"
	HuggingFaceProvider = "huggingface"
	OpenAIProvider      = "openai"
)
View Source
const (
	Text2sqlType = "Text2sql"
	SQLFixType   = "SqlFix"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AIConfig

type AIConfig struct {
	Name        string
	AuthToken   string
	BaseURL     string
	Model       string
	Temperature float32
	TopP        float32
}

AIConfig represents the configuration settings for an AI client.

func ConvertToAIConfig

func ConvertToAIConfig(c registry.ExtraConfig) AIConfig

type AIProvider

type AIProvider interface {
	// Configure sets up the AI service with the provided configuration.
	Configure(config AIConfig) error
	// Generate generates a response from the AI service based on
	// the provided prompt and service type.
	Generate(ctx context.Context, prompt string) (string, error)
	// GenerateStream generates a streaming response from the AI service
	// based on the provided prompt. It returns a channel that will receive
	// chunks of the response as they are generated.
	GenerateStream(ctx context.Context, prompt string) (<-chan string, error)
}

AIProvider is an interface all AI clients.

func NewClient

func NewClient(name string) AIProvider

NewClient returns a new AIProvider object

type AzureAIClient

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

func (*AzureAIClient) Configure

func (c *AzureAIClient) Configure(cfg AIConfig) error

func (*AzureAIClient) Generate

func (c *AzureAIClient) Generate(ctx context.Context, prompt string) (string, error)

func (*AzureAIClient) GenerateStream

func (c *AzureAIClient) GenerateStream(ctx context.Context, prompt string) (<-chan string, error)

type HuggingfaceClient

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

func (*HuggingfaceClient) Configure

func (c *HuggingfaceClient) Configure(cfg AIConfig) error

func (*HuggingfaceClient) Generate

func (c *HuggingfaceClient) Generate(ctx context.Context, prompt string) (string, error)

func (*HuggingfaceClient) GenerateStream

func (c *HuggingfaceClient) GenerateStream(ctx context.Context, prompt string) (<-chan string, error)

type OpenAIClient

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

func (*OpenAIClient) Configure

func (c *OpenAIClient) Configure(cfg AIConfig) error

func (*OpenAIClient) Generate

func (c *OpenAIClient) Generate(ctx context.Context, prompt string) (string, error)

func (*OpenAIClient) GenerateStream

func (c *OpenAIClient) GenerateStream(ctx context.Context, prompt string) (<-chan string, error)

Jump to

Keyboard shortcuts

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