Help us shape the future of Go! Take the 2026 Go Developer Survey

provider

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfigValidators

func DefaultConfigValidators() map[string]ConfigValidator

DefaultConfigValidators 返回内建 Provider 的配置校验器。

func DefaultFactories

func DefaultFactories() map[string]Factory

DefaultFactories returns built-in provider factories keyed by ProviderConfig.Kind.

Types

type BaiduError

type BaiduError struct {
	Status  int
	Code    int
	Message string
	Raw     string
}

BaiduError represents errors returned by Baidu OCR API.

func (*BaiduError) Error

func (e *BaiduError) Error() string

func (*BaiduError) ErrorCategory

func (e *BaiduError) ErrorCategory() string

type ConfigValidator

type ConfigValidator func(*config.ProviderConfig) error

ConfigValidator 用于在构建 Provider 前补全和校验配置。

type ErrorCategorizer

type ErrorCategorizer interface {
	ErrorCategory() string
}

TextInError 表示 TextIn API 返回的错误。

type Factory

type Factory func(config.ProviderConfig) (Provider, error)

Factory constructs providers from configuration.

type Provider

type Provider interface {
	Call(ctx context.Context, req Request) (Response, error)
}

Provider defines the contract for upstream OCR services.

func NewBaiduProvider

func NewBaiduProvider(cfg config.ProviderConfig) (Provider, error)

NewBaiduProvider constructs a Baidu OCR provider.

func NewTextInProvider

func NewTextInProvider(cfg config.ProviderConfig) (Provider, error)

NewTextInProvider constructs a TextIn OCR provider.

func NewVolcEngineProvider

func NewVolcEngineProvider(cfg config.ProviderConfig) (Provider, error)

NewVolcEngineProvider 构造火山引擎 OCR Provider。

type Registry

type Registry map[string]Factory

Registry allows registering providers by kind.

func (Registry) Lookup

func (r Registry) Lookup(kind string) (Factory, error)

Lookup resolves provider factory by kind.

type Request

type Request struct {
	FilePath      string
	IsRemote      bool
	NeedCharacter bool
	Options       map[string]any
}

Request captures the payload sent to an OCR provider.

type Response

type Response struct {
	Raw       []byte
	MediaType string
	Stats     map[string]any
}

Response is the generic provider response container.

type TextInError

type TextInError struct {
	Status   int
	Code     int
	Message  string
	Raw      string
	Category string
}

TextInError 表示 TextIn API 返回的错误。

func (*TextInError) Error

func (e *TextInError) Error() string

func (*TextInError) ErrorCategory

func (e *TextInError) ErrorCategory() string

ErrorCategory 实现 ErrorCategorizer,用于归类 provider 错误。

type VolcError

type VolcError struct {
	Status  int
	Code    int
	Message string
	Raw     string
}

func (*VolcError) Error

func (e *VolcError) Error() string

func (*VolcError) ErrorCategory

func (e *VolcError) ErrorCategory() string

ErrorCategory 实现 ErrorCategorizer 接口。

Jump to

Keyboard shortcuts

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