route

package
v1.36.3 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeCacheKeyForChatCompletionRequest added in v1.7.1

func ComputeCacheKeyForChatCompletionRequest(path string, req *goopenai.ChatCompletionRequest) string

func ComputeCacheKeyForEmbeddingsRequest added in v1.7.1

func ComputeCacheKeyForEmbeddingsRequest(path string, req *goopenai.EmbeddingRequest) string

func ConvertToArrayOfStrings added in v1.25.0

func ConvertToArrayOfStrings(input []any) []string

func ConvertToMapOfIntegers added in v1.25.0

func ConvertToMapOfIntegers(input any) map[string]int

func InitializeBackoff added in v1.29.0

func InitializeBackoff(strategy string, dur time.Duration) backoff.BackOff

Types

type CacheConfig

type CacheConfig struct {
	Enabled bool   `json:"enabled"`
	Ttl     string `json:"ttl"`
}

type Request

type Request struct {
	Settings      map[string]*provider.Setting
	Key           *key.ResponseKey
	Client        http.Client
	Forwarded     *http.Request
	Start         time.Time
	CustomId      string
	Request       []byte
	Response      []byte
	UserId        string
	PolicyId      string
	Action        string
	CorrelationId string
}

func (*Request) GetSettingValue

func (r *Request) GetSettingValue(provider string, param string) (string, error)

type Response

type Response struct {
	Provider string
	Model    string
	Data     []byte
	Cancel   context.CancelFunc
	Response *http.Response
}

type Route

type Route struct {
	Id            string       `json:"id"`
	RetryStrategy string       `json:"retryStrategy"`
	RequestFormat string       `json:"requestFormat"`
	CreatedAt     int64        `json:"createdAt"`
	UpdatedAt     int64        `json:"updatedAt"`
	Name          string       `json:"name"`
	Path          string       `json:"path"`
	KeyIds        []string     `json:"keyIds"`
	Steps         []*Step      `json:"steps"`
	CacheConfig   *CacheConfig `json:"cacheConfig"`
}

func (*Route) RunSteps

func (r *Route) RunSteps(req *Request, rec recorder, log *zap.Logger) (*Response, error)

func (*Route) RunStepsV2 added in v1.29.0

func (r *Route) RunStepsV2(req *Request, rec recorder, log *zap.Logger, kc *key.ResponseKey) (*Response, error)

func (*Route) ShouldRunEmbeddings

func (r *Route) ShouldRunEmbeddings() bool

func (*Route) ValidateSettings

func (r *Route) ValidateSettings(settings []*provider.Setting) bool

type Step

type Step struct {
	Retries       int               `json:"retries"`
	RetryInterval string            `json:"retryInterval"`
	Provider      string            `json:"provider"`
	RequestParams map[string]any    `json:"requestParams"`
	Params        map[string]string `json:"params"`
	Model         string            `json:"model"`
	Timeout       string            `json:"timeout"`
}

func (*Step) DecorateChatCompletionRequest added in v1.25.0

func (s *Step) DecorateChatCompletionRequest(req *goopenai.ChatCompletionRequest)

func (*Step) DecorateRequest added in v1.29.0

func (s *Step) DecorateRequest(provider string, body []byte, isEmbedding bool) ([]byte, error)

Jump to

Keyboard shortcuts

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