Skip to main content

aireducer

函数名函数描述/介绍
aireducer.File
aireducer.NewReducerFromFile
aireducer.NewReducerFromReader
aireducer.NewReducerFromString
aireducer.Reader
aireducer.String
aireducer.callback
aireducer.chunkSize
aireducer.context
aireducer.lineNumberWithEnableLineNumber enables line number prefixing for chunk content. When enabled, each line in the chunk will be prefixed with line numbers. This op...
aireducer.linesWithLines sets the line trigger for chunking. When set to a positive value, chunks will be created every N lines. If the N lines content is smaller t...
aireducer.memory
aireducer.reducerCallback
aireducer.separator
aireducer.timeTriggerInterval
aireducer.timeTriggerIntervalSeconds

函数定义#

File#

详细描述#

定义#

File(filename string, callback func(chunk chunkmaker.Chunk), options ...Option) error

参数#

参数名参数类型参数解释
filenamestring
callbackfunc(chunk chunkmaker.Chunk)
options...Option

返回值#

返回值(顺序)返回值类型返回值解释
r1error

NewReducerFromFile#

详细描述#

定义#

NewReducerFromFile(filename string, opts ...Option) (*Reducer, error)

参数#

参数名参数类型参数解释
filenamestring
opts...Option

返回值#

返回值(顺序)返回值类型返回值解释
r1*Reducer
r2error

NewReducerFromReader#

详细描述#

定义#

NewReducerFromReader(r io.Reader, opts ...Option) (*Reducer, error)

参数#

参数名参数类型参数解释
rio.Reader
opts...Option

返回值#

返回值(顺序)返回值类型返回值解释
r1*Reducer
r2error

NewReducerFromString#

详细描述#

定义#

NewReducerFromString(i string, opts ...Option) (*Reducer, error)

参数#

参数名参数类型参数解释
istring
opts...Option

返回值#

返回值(顺序)返回值类型返回值解释
r1*Reducer
r2error

Reader#

详细描述#

定义#

Reader(i io.Reader, callback func(chunk chunkmaker.Chunk), options ...Option) error

参数#

参数名参数类型参数解释
iio.Reader
callbackfunc(chunk chunkmaker.Chunk)
options...Option

返回值#

返回值(顺序)返回值类型返回值解释
r1error

String#

详细描述#

定义#

String(s string, callback func(chunk chunkmaker.Chunk), options ...Option) error

参数#

参数名参数类型参数解释
sstring
callbackfunc(chunk chunkmaker.Chunk)
options...Option

返回值#

返回值(顺序)返回值类型返回值解释
r1error

callback#

详细描述#

定义#

callback(callback ReducerCallbackType) Option

参数#

参数名参数类型参数解释
callbackReducerCallbackType

返回值#

返回值(顺序)返回值类型返回值解释
r1Option

chunkSize#

详细描述#

定义#

chunkSize(size int64) Option

参数#

参数名参数类型参数解释
sizeint64

返回值#

返回值(顺序)返回值类型返回值解释
r1Option

context#

详细描述#

定义#

context(ctx context.Context) Option

参数#

参数名参数类型参数解释
ctxcontext.Context

返回值#

返回值(顺序)返回值类型返回值解释
r1Option

lineNumber#

详细描述#

WithEnableLineNumber enables line number prefixing for chunk content. When enabled, each line in the chunk will be prefixed with line numbers. This option works with all chunking modes and respects ChunkSize limits.

定义#

lineNumber(enable bool) Option

参数#

参数名参数类型参数解释
enablebool

返回值#

返回值(顺序)返回值类型返回值解释
r1Option

lines#

详细描述#

WithLines sets the line trigger for chunking. When set to a positive value,

chunks will be created every N lines. If the N lines content is smaller than

ChunkSize, it will be kept intact. If larger than ChunkSize, it will be split

according to ChunkSize (ChunkSize is a hard limit).

Example:


    aireducer.NewReducerFromFile("file.txt", aireducer.WithLines(10), aireducer.WithChunkSize(1024))    // This will create chunks every 10 lines, but if 10 lines exceed 1024 bytes,    // they will be split at 1024 byte boundaries.

定义#

lines(lines int) Option

参数#

参数名参数类型参数解释
linesint

返回值#

返回值(顺序)返回值类型返回值解释
r1Option

memory#

详细描述#

定义#

memory(memory *aid.PromptContextProvider) Option

参数#

参数名参数类型参数解释
memory*aid.PromptContextProvider

返回值#

返回值(顺序)返回值类型返回值解释
r1Option

reducerCallback#

详细描述#

定义#

reducerCallback(callback ReducerCallbackType) Option

参数#

参数名参数类型参数解释
callbackReducerCallbackType

返回值#

返回值(顺序)返回值类型返回值解释
r1Option

separator#

详细描述#

定义#

separator(separator string) Option

参数#

参数名参数类型参数解释
separatorstring

返回值#

返回值(顺序)返回值类型返回值解释
r1Option

timeTriggerInterval#

详细描述#

定义#

timeTriggerInterval(interval time.Duration) Option

参数#

参数名参数类型参数解释
intervaltime.Duration

返回值#

返回值(顺序)返回值类型返回值解释
r1Option

timeTriggerIntervalSeconds#

详细描述#

定义#

timeTriggerIntervalSeconds(seconds float64) Option

参数#

参数名参数类型参数解释
secondsfloat64

返回值#

返回值(顺序)返回值类型返回值解释
r1Option