Documentation
¶
Index ¶
- Constants
- func DocumentFailure(err error) error
- func FormatCurrency(cost Currency) string
- func GlobalFailure(err error) error
- func IsGeminiAmbiguousOperation(err error) bool
- func IsGeminiBatchNotFound(err error) bool
- func IsGeminiDeleteInvalidArgument(err error) bool
- func IsGeminiGlobalFailure(err error) bool
- func IsGeminiMaxTokensError(err error) bool
- func IsGeminiRangeSizeError(err error) bool
- func MistralPricePerPage() float64
- func NormalizeGeminiBatchState(remoteState string) (string, error)
- func TemporaryFailure(err error) error
- type BillingReport
- type Currency
- func GeminiBatchCost(at time.Time, inputTokens, outputTokens int64) Currency
- func GeminiCost(at time.Time, inputTokens, outputTokens int64) Currency
- func GeminiCostWithPrices(prices GeminiTokenPrices, inputTokens, outputTokens int64) Currency
- func MistralCost(pages int) Currency
- func MistralPageCost() Currency
- type Failure
- type FailureKind
- type GeminiAmbiguousOperationError
- type GeminiBatchAPIError
- type GeminiBatchTransport
- func (c *GeminiBatchTransport) CancelBatch(ctx context.Context, name string) error
- func (c *GeminiBatchTransport) CreateBatch(ctx context.Context, model, displayName, inputFileName string) (GeminiRemoteBatch, error)
- func (c *GeminiBatchTransport) DeleteBatch(ctx context.Context, name string) error
- func (c *GeminiBatchTransport) DeleteFile(ctx context.Context, name string) error
- func (c *GeminiBatchTransport) DownloadFile(ctx context.Context, name string) (io.ReadCloser, error)
- func (c *GeminiBatchTransport) GetBatch(ctx context.Context, name string) (GeminiRemoteBatch, error)
- func (c *GeminiBatchTransport) ListBatches(ctx context.Context) ([]GeminiRemoteBatch, error)
- func (c *GeminiBatchTransport) ListFiles(ctx context.Context) ([]GeminiRemoteFile, error)
- func (c *GeminiBatchTransport) UploadJSONL(ctx context.Context, displayName string, source io.ReadSeeker, size int64) (GeminiRemoteFile, error)
- type GeminiClient
- func (c *GeminiClient) OCRFile(ctx context.Context, filePath string, fileType string) ([]PageResult, BillingReport, error)
- func (c *GeminiClient) OCRRange(ctx context.Context, filePath, fileType string, start, end int) ([]PageResult, BillingReport, error)
- func (c *GeminiClient) OCRRangeResult(ctx context.Context, filePath, fileType string, start, end int) (RangeResult, error)
- func (c *GeminiClient) PrepareFileRequests(ctx context.Context, filePath, fileType string) ([]GeminiPreparedRequest, error)
- func (c *GeminiClient) PrepareRangeRequest(ctx context.Context, filePath, fileType string, start, end int) (GeminiPreparedRequest, error)
- func (c *GeminiClient) WalkFileRequests(ctx context.Context, filePath, fileType string, ...) error
- type GeminiDecodedResult
- type GeminiPlanningError
- type GeminiPreparedRequest
- type GeminiRangeSizeError
- type GeminiRemoteBatch
- type GeminiRemoteFile
- type GeminiTokenPrices
- type MistralClient
- type PageResult
- type Provider
- type RangeResult
Constants ¶
const ( GeminiDirectModel = geminiModel GeminiBatchModel = geminiModel // Reserve 100 MB below Gemini's 2 GB uploaded-input limit so framing and // provider-side size accounting cannot turn an exactly packed job invalid. GeminiBatchMaxInputBytes = int64(1_900_000_000) GeminiBatchMaxResponseBytes = geminiMaxResponseBytes )
const (
MistralModel = mistralModel
)
Variables ¶
This section is empty.
Functions ¶
func DocumentFailure ¶ added in v0.3.0
func FormatCurrency ¶ added in v0.3.0
func GlobalFailure ¶ added in v0.3.0
func IsGeminiAmbiguousOperation ¶ added in v0.3.0
func IsGeminiBatchNotFound ¶ added in v0.3.0
func IsGeminiDeleteInvalidArgument ¶ added in v0.3.0
func IsGeminiGlobalFailure ¶ added in v0.3.0
func IsGeminiMaxTokensError ¶ added in v0.3.0
func IsGeminiRangeSizeError ¶ added in v0.3.0
func MistralPricePerPage ¶
func MistralPricePerPage() float64
func NormalizeGeminiBatchState ¶ added in v0.3.0
func TemporaryFailure ¶ added in v0.3.0
Types ¶
type BillingReport ¶ added in v0.3.0
func (*BillingReport) Add ¶ added in v0.3.0
func (r *BillingReport) Add(other BillingReport)
type Currency ¶ added in v0.3.0
type Currency int64
Currency is stored as billionths of a US dollar. That precision represents every baked-in per-token and per-page price exactly without concurrent float arithmetic.
func GeminiBatchCost ¶ added in v0.3.0
func GeminiCost ¶ added in v0.3.0
func GeminiCostWithPrices ¶ added in v0.3.0
func GeminiCostWithPrices(prices GeminiTokenPrices, inputTokens, outputTokens int64) Currency
func MistralCost ¶ added in v0.3.0
func MistralPageCost ¶ added in v0.3.0
func MistralPageCost() Currency
type Failure ¶ added in v0.3.0
type Failure struct {
Kind FailureKind
Err error
}
type FailureKind ¶ added in v0.3.0
type FailureKind string
const ( FailureUnclassified FailureKind = "unclassified" FailureTemporary FailureKind = "temporary" FailureDocument FailureKind = "document" FailureGlobal FailureKind = "global" )
func ClassifyFailure ¶ added in v0.3.0
func ClassifyFailure(err error) FailureKind
Fallback is deliberately conservative because advancing the chain can incur another provider charge. Only verified permanent document/content failures advance; temporary and ambiguous failures stay pending for a later run.
type GeminiAmbiguousOperationError ¶ added in v0.3.0
func (*GeminiAmbiguousOperationError) Error ¶ added in v0.3.0
func (e *GeminiAmbiguousOperationError) Error() string
func (*GeminiAmbiguousOperationError) Unwrap ¶ added in v0.3.0
func (e *GeminiAmbiguousOperationError) Unwrap() error
type GeminiBatchAPIError ¶ added in v0.3.0
func (*GeminiBatchAPIError) Error ¶ added in v0.3.0
func (e *GeminiBatchAPIError) Error() string
type GeminiBatchTransport ¶ added in v0.3.0
type GeminiBatchTransport struct {
// contains filtered or unexported fields
}
GeminiBatchTransport keeps the discounted Batch API's Files and batch-job lifecycle explicit instead of hiding non-idempotent calls behind an SDK.
func NewGeminiBatchTransport ¶ added in v0.3.0
func NewGeminiBatchTransport(apiKey string) *GeminiBatchTransport
func (*GeminiBatchTransport) CancelBatch ¶ added in v0.3.0
func (c *GeminiBatchTransport) CancelBatch(ctx context.Context, name string) error
func (*GeminiBatchTransport) CreateBatch ¶ added in v0.3.0
func (c *GeminiBatchTransport) CreateBatch( ctx context.Context, model, displayName, inputFileName string, ) (GeminiRemoteBatch, error)
func (*GeminiBatchTransport) DeleteBatch ¶ added in v0.3.0
func (c *GeminiBatchTransport) DeleteBatch(ctx context.Context, name string) error
func (*GeminiBatchTransport) DeleteFile ¶ added in v0.3.0
func (c *GeminiBatchTransport) DeleteFile(ctx context.Context, name string) error
func (*GeminiBatchTransport) DownloadFile ¶ added in v0.3.0
func (c *GeminiBatchTransport) DownloadFile(ctx context.Context, name string) (io.ReadCloser, error)
func (*GeminiBatchTransport) GetBatch ¶ added in v0.3.0
func (c *GeminiBatchTransport) GetBatch(ctx context.Context, name string) (GeminiRemoteBatch, error)
func (*GeminiBatchTransport) ListBatches ¶ added in v0.3.0
func (c *GeminiBatchTransport) ListBatches(ctx context.Context) ([]GeminiRemoteBatch, error)
func (*GeminiBatchTransport) ListFiles ¶ added in v0.3.0
func (c *GeminiBatchTransport) ListFiles(ctx context.Context) ([]GeminiRemoteFile, error)
func (*GeminiBatchTransport) UploadJSONL ¶ added in v0.3.0
func (c *GeminiBatchTransport) UploadJSONL( ctx context.Context, displayName string, source io.ReadSeeker, size int64, ) (GeminiRemoteFile, error)
type GeminiClient ¶ added in v0.3.0
type GeminiClient struct {
// contains filtered or unexported fields
}
func NewGeminiClient ¶ added in v0.3.0
func NewGeminiClient(apiKey string, runAt time.Time) *GeminiClient
func NewGeminiClientFromEnv ¶ added in v0.3.0
func NewGeminiClientFromEnv(runAt time.Time) (*GeminiClient, error)
func (*GeminiClient) OCRFile ¶ added in v0.3.0
func (c *GeminiClient) OCRFile(ctx context.Context, filePath string, fileType string) ([]PageResult, BillingReport, error)
func (*GeminiClient) OCRRange ¶ added in v0.3.0
func (c *GeminiClient) OCRRange( ctx context.Context, filePath, fileType string, start, end int, ) ([]PageResult, BillingReport, error)
func (*GeminiClient) OCRRangeResult ¶ added in v0.3.0
func (c *GeminiClient) OCRRangeResult( ctx context.Context, filePath, fileType string, start, end int, ) (RangeResult, error)
func (*GeminiClient) PrepareFileRequests ¶ added in v0.3.0
func (c *GeminiClient) PrepareFileRequests(ctx context.Context, filePath, fileType string) ([]GeminiPreparedRequest, error)
func (*GeminiClient) PrepareRangeRequest ¶ added in v0.3.0
func (c *GeminiClient) PrepareRangeRequest( ctx context.Context, filePath, fileType string, start, end int, ) (GeminiPreparedRequest, error)
func (*GeminiClient) WalkFileRequests ¶ added in v0.3.0
func (c *GeminiClient) WalkFileRequests( ctx context.Context, filePath, fileType string, yield func(GeminiPreparedRequest) error, reject func(*GeminiRangeSizeError) error, ) error
type GeminiDecodedResult ¶ added in v0.3.0
type GeminiDecodedResult struct {
Pages []PageResult
InputTokens *int64
OutputTokens *int64
Billing BillingReport
}
func DecodeGeminiBatchResult ¶ added in v0.3.0
func DecodeGeminiBatchResult( body []byte, expectedPages int, prices GeminiTokenPrices, ) (GeminiDecodedResult, error)
type GeminiPlanningError ¶ added in v0.3.0
func (*GeminiPlanningError) Error ¶ added in v0.3.0
func (e *GeminiPlanningError) Error() string
func (*GeminiPlanningError) Unwrap ¶ added in v0.3.0
func (e *GeminiPlanningError) Unwrap() error
type GeminiPreparedRequest ¶ added in v0.3.0
GeminiClient uses the REST API directly so the OCR provider has no SDK dependency and its request and billing behavior remain explicit.
type GeminiRangeSizeError ¶ added in v0.3.0
func (*GeminiRangeSizeError) Error ¶ added in v0.3.0
func (e *GeminiRangeSizeError) Error() string
func (*GeminiRangeSizeError) Unwrap ¶ added in v0.3.0
func (e *GeminiRangeSizeError) Unwrap() error
type GeminiRemoteBatch ¶ added in v0.3.0
type GeminiRemoteFile ¶ added in v0.3.0
type GeminiTokenPrices ¶ added in v0.3.0
func GeminiBatchPrices ¶ added in v0.3.0
func GeminiBatchPrices(at time.Time) GeminiTokenPrices
func GeminiPrices ¶ added in v0.3.0
func GeminiPrices(at time.Time) GeminiTokenPrices
Gemini's standard paid rates change at the documented UTC pricing cutover. Keep estimates and actual usage on the run's single schedule even if workers cross midnight. Recheck against https://ai.google.dev/gemini-api/docs/pricing.
type MistralClient ¶
type MistralClient struct {
// contains filtered or unexported fields
}
func NewMistralClient ¶
func NewMistralClient(apiKey string) *MistralClient
func NewMistralClientFromEnv ¶
func NewMistralClientFromEnv() (*MistralClient, error)
func (*MistralClient) OCRFile ¶
func (c *MistralClient) OCRFile(ctx context.Context, filePath string, fileType string) ([]PageResult, BillingReport, error)
func (*MistralClient) OCRRangeResult ¶ added in v0.3.0
func (c *MistralClient) OCRRangeResult( ctx context.Context, filePath, fileType string, start, end int, ) (RangeResult, error)
func (*MistralClient) PricePerPage ¶
func (c *MistralClient) PricePerPage() float64
type PageResult ¶
type Provider ¶
type Provider interface {
OCRRangeResult(
ctx context.Context,
filePath string,
fileType string,
start int,
end int,
) (RangeResult, error)
}
Provider processes only a requested source-page range so successful pages from earlier models or runs never need to be sent over the network again.
type RangeResult ¶ added in v0.3.0
type RangeResult struct {
Pages []PageResult
Billing BillingReport
}