ai

package
v0.0.55 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PromptMap = map[string]string{
	"default":                       default_prompt,
	"PrometheusConfigValidate":      prom_conf_prompt,
	"PrometheusConfigRelabelReport": prom_relabel_prompt,
	"PolicyReport":                  kyverno_prompt,
	"ClusterPolicyReport":           kyverno_prompt,
}

Functions

func NeedPassword

func NeedPassword(backend string) bool

Types

type Configuration

type Configuration struct {
	Providers       []Provider
	DefaultProvider string
}

type IAI

type IAI interface {
	Configure(config IAIConfig) error
	GetCompletion(ctx context.Context, prompt string) (string, error)
	GetStreamCompletion(ctx context.Context, prompt string) (*openai.ChatCompletionStream, error)
	GetName() string
	Close()
}

func NewClient

func NewClient(provider string) IAI

type IAIConfig

type IAIConfig interface {
	GetPassword() string
	GetModel() string
	GetBaseURL() string
	GetProxyEndpoint() string
	GetEndpointName() string
	GetEngine() string
	GetTemperature() float32
	GetProviderRegion() string
	GetTopP() float32
	GetTopK() int32
	GetMaxTokens() int
	GetProviderId() string
	GetCompartmentId() string
	GetOrganizationId() string
	GetCustomHeaders() []http.Header
}

type OpenAIClient

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

func (OpenAIClient) Close

func (OpenAIClient) Close()

func (*OpenAIClient) Configure

func (c *OpenAIClient) Configure(config IAIConfig) error

func (*OpenAIClient) GetCompletion

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

func (*OpenAIClient) GetName

func (c *OpenAIClient) GetName() string

func (*OpenAIClient) GetStreamCompletion

func (c *OpenAIClient) GetStreamCompletion(ctx context.Context, prompt string) (*openai.ChatCompletionStream, error)

type OpenAIHeaderTransport

type OpenAIHeaderTransport struct {
	Origin  http.RoundTripper
	Headers []http.Header
}

OpenAIHeaderTransport is an http.RoundTripper that adds the given headers to each request.

func (*OpenAIHeaderTransport) RoundTrip

func (t *OpenAIHeaderTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the http.RoundTripper interface.

type Provider

type Provider struct {
	Name           string
	Model          string
	Password       string
	BaseURL        string
	ProxyEndpoint  string
	ProxyPort      string
	EndpointName   string
	Engine         string
	Temperature    float32
	ProviderRegion string
	ProviderId     string
	CompartmentId  string
	TopP           float32
	TopK           int32
	MaxTokens      int
	OrganizationId string
	CustomHeaders  []http.Header
}

func (*Provider) GetBaseURL

func (p *Provider) GetBaseURL() string

func (*Provider) GetCompartmentId

func (p *Provider) GetCompartmentId() string

func (*Provider) GetCustomHeaders

func (p *Provider) GetCustomHeaders() []http.Header

func (*Provider) GetEndpointName

func (p *Provider) GetEndpointName() string

func (*Provider) GetEngine

func (p *Provider) GetEngine() string

func (*Provider) GetMaxTokens

func (p *Provider) GetMaxTokens() int

func (*Provider) GetModel

func (p *Provider) GetModel() string

func (*Provider) GetOrganizationId

func (p *Provider) GetOrganizationId() string

func (*Provider) GetPassword

func (p *Provider) GetPassword() string

func (*Provider) GetProviderId

func (p *Provider) GetProviderId() string

func (*Provider) GetProviderRegion

func (p *Provider) GetProviderRegion() string

func (*Provider) GetProxyEndpoint

func (p *Provider) GetProxyEndpoint() string

func (*Provider) GetTemperature

func (p *Provider) GetTemperature() float32

func (*Provider) GetTopK

func (p *Provider) GetTopK() int32

func (*Provider) GetTopP

func (p *Provider) GetTopP() float32

Jump to

Keyboard shortcuts

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