Documentation
¶
Index ¶
Constants ¶
View Source
const ( DefaultInstructionModel = "gpt-3.5-turbo-instruct" DefaultAPIBaseURL = "https://api.openai.com/v1" DefaultMaxTokenCount = 2048 DefaultLocale = "zh_CN" DefaultRequestsPerSecond = math.MaxInt16 )
View Source
const ( StableCodeModel = "stable-code" DeepSeekCoderModel = "deepseek-coder" )
Variables ¶
View Source
var CustomTextLogEncoderConfig = zapcore.EncoderConfig{ TimeKey: "time", LevelKey: "level", NameKey: "logger", CallerKey: "caller", MessageKey: "msg", StacktraceKey: "stacktrace", LineEnding: zapcore.DefaultLineEnding, EncodeTime: func(t time.Time, enc zapcore.PrimitiveArrayEncoder) { formatLogEntry(t, enc) }, EncodeDuration: func(d time.Duration, enc zapcore.PrimitiveArrayEncoder) { formatLogEntry(d, enc) }, EncodeCaller: func(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder) { formatLogEntry(caller, enc) }, EncodeLevel: func(level zapcore.Level, enc zapcore.PrimitiveArrayEncoder) { formatLogEntry(level, enc) }, EncodeName: func(name string, enc zapcore.PrimitiveArrayEncoder) { formatLogEntry(name, enc) }, }
View Source
var ErrorConfigureTransport = errors.New("config transport failed")
Functions ¶
func AuthMiddleware ¶
func AuthMiddleware(authToken string) gin.HandlerFunc
func NewLumberjackLogger ¶
func NewLumberjackLogger(path string) *lumberjack.Logger
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func (*Logger) GetZapSugaredLogger ¶
func (cl *Logger) GetZapSugaredLogger() *zap.SugaredLogger
type ProxyService ¶
type ProxyService struct {
// contains filtered or unexported fields
}
func NewProxyService ¶
func NewProxyService(config *ServiceConfig, logger *logr.Logger, limiter *rl.RateLimiter) (*ProxyService, error)
func (*ProxyService) RegisterGroup ¶
func (ps *ProxyService) RegisterGroup(g *gin.RouterGroup)
type ServiceConfig ¶
type ServiceConfig struct { BindAddress string `json:"bind,omitempty"` ProxyURL string `json:"proxy_url,omitempty"` TimeoutSeconds int `json:"timeout,omitempty"` CodexAPIBaseURL string `json:"codex_api_base,omitempty"` CodexAPIKey string `json:"codex_api_key,omitempty"` CodexAPIOrganization string `json:"codex_api_organization,omitempty"` CodexAPIProject string `json:"codex_api_project,omitempty"` CodexMaxTokenCount int `json:"codex_max_tokens,omitempty"` CodeInstructionModel string `json:"code_instruct_model,omitempty"` ChatAPIBaseURL string `json:"chat_api_base,omitempty"` ChatAPIKey string `json:"chat_api_key,omitempty"` ChatAPIOrganization string `json:"chat_api_organization,omitempty"` ChatAPIProject string `json:"chat_api_project,omitempty"` ChatMaxTokenCount int `json:"chat_max_tokens,omitempty"` ChatDefaultModel string `json:"chat_model_default,omitempty"` ChatModelMapping map[string]string `json:"chat_model_map,omitempty"` ChatLocale string `json:"chat_locale,omitempty"` AuthToken string `json:"auth_token,omitempty"` MaxRequestsPerSecond int `json:"requests_per_sec,omitempty"` }
func NewServiceConfig ¶
func NewServiceConfig() *ServiceConfig
func (*ServiceConfig) LoadConfig ¶
func (sc *ServiceConfig) LoadConfig(filePath string) error
func (*ServiceConfig) String ¶
func (c *ServiceConfig) String() string
Click to show internal directories.
Click to hide internal directories.