route

package
v1.25.3 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: MIT Imports: 15 Imported by: 0

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

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
	CorrelationId string
	Cancel        context.CancelFunc
	Response      *http.Response
}

type Route

type Route struct {
	Id            string       `json:"id"`
	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) 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"`
	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)

Jump to

Keyboard shortcuts

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