azure

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthHeaderKey = "api-key"
)

Variables

This section is empty.

Functions

func Init added in v1.2.0

func Init() error

func InitFromConfigFile added in v1.3.5

func InitFromConfigFile() error

func InitFromEnvironmentVariables added in v1.3.5

func InitFromEnvironmentVariables(apiVersion, endpoint, openaiModelMapper string)

func ModelProxy added in v1.3.8

func ModelProxy(c *gin.Context)

func Proxy

func Proxy(c *gin.Context, requestConverter RequestConverter)

Proxy Azure OpenAI

func ProxyWithConverter added in v1.3.5

func ProxyWithConverter(requestConverter RequestConverter) gin.HandlerFunc

Types

type Config added in v1.3.5

type Config struct {
	ApiBase          string             `yaml:"api_base" mapstructure:"api_base"`                   // if you use openai、langchain as sdk, it will be useful
	DeploymentConfig []DeploymentConfig `yaml:"deployment_config" mapstructure:"deployment_config"` // deployment config
}
var (
	C                     Config
	ModelDeploymentConfig = map[string]DeploymentConfig{}
)

type DeploymentConfig added in v1.3.5

type DeploymentConfig struct {
	DeploymentName string   `yaml:"deployment_name" json:"deployment_name" mapstructure:"deployment_name"` // azure openai deployment name
	ModelName      string   `yaml:"model_name" json:"model_name" mapstructure:"model_name"`                // corresponding model name in openai
	Endpoint       string   `yaml:"endpoint" json:"endpoint" mapstructure:"endpoint"`                      // deployment endpoint
	ApiKey         string   `yaml:"api_key" json:"api_key" mapstructure:"api_key"`                         // secrect key1 or 2
	ApiVersion     string   `yaml:"api_version" json:"api_version" mapstructure:"api_version"`             // deployment version, not required
	EndpointUrl    *url.URL // url.URL form deployment endpoint
}

func GetDeploymentByModel

func GetDeploymentByModel(model string) (*DeploymentConfig, error)

type DeploymentInfo added in v1.3.8

type DeploymentInfo struct {
	Data   []map[string]interface{} `json:"data"`
	Object string                   `json:"object"`
}

type RequestConverter added in v1.3.5

type RequestConverter interface {
	Name() string
	Convert(req *http.Request, config *DeploymentConfig) (*http.Request, error)
}

type StripPrefixConverter added in v1.3.5

type StripPrefixConverter struct {
	Prefix string
}

func NewStripPrefixConverter added in v1.3.5

func NewStripPrefixConverter(prefix string) *StripPrefixConverter

func (*StripPrefixConverter) Convert added in v1.3.5

func (c *StripPrefixConverter) Convert(req *http.Request, config *DeploymentConfig) (*http.Request, error)

func (*StripPrefixConverter) Name added in v1.3.5

func (c *StripPrefixConverter) Name() string

type TemplateConverter added in v1.3.5

type TemplateConverter struct {
	Tpl      string
	Tempalte *template.Template
}

func NewTemplateConverter added in v1.3.5

func NewTemplateConverter(tpl string) *TemplateConverter

func (*TemplateConverter) Convert added in v1.3.5

func (c *TemplateConverter) Convert(req *http.Request, config *DeploymentConfig) (*http.Request, error)

func (*TemplateConverter) Name added in v1.3.5

func (c *TemplateConverter) Name() string

Jump to

Keyboard shortcuts

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