azure

package
v0.0.0-...-feaeec3 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func Init

func Init() error

func InitFromConfigFile

func InitFromConfigFile() error

func InitFromEnvironmentVariables

func InitFromEnvironmentVariables(apiVersion, endpoint, openaiModelMapper string)

func ModelProxy

func ModelProxy(c *gin.Context)

func Proxy

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

Proxy Azure OpenAI

func ProxyWithConverter

func ProxyWithConverter(requestConverter RequestConverter) gin.HandlerFunc

Types

type Config

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

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

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

type RequestConverter

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

type StripPrefixConverter

type StripPrefixConverter struct {
	Prefix string
}

func NewStripPrefixConverter

func NewStripPrefixConverter(prefix string) *StripPrefixConverter

func (*StripPrefixConverter) Convert

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

func (*StripPrefixConverter) Name

func (c *StripPrefixConverter) Name() string

type TemplateConverter

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

func NewTemplateConverter

func NewTemplateConverter(tpl string) *TemplateConverter

func (*TemplateConverter) Convert

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

func (*TemplateConverter) Name

func (c *TemplateConverter) Name() string

Jump to

Keyboard shortcuts

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