Class ChatBatchTransformation<TInput, TOutput>

Sends each batch to an Microsoft.Extensions.AI.IChatClient as one request and emits the returned rows in the order they came back. The batch is sent as {"Items":[...]} and the same envelope is expected in the response. Set RequireSameItemCount to enforce one item per input row. Default batch size is 10.

Inherited Members
Namespace: ETLBox.AI
Assembly: ETLBox.AI.dll
Syntax
    public class ChatBatchTransformation<TInput, TOutput> : DataFlowTransformation<TInput, TOutput>, IDataFlowTransformation<TInput, TOutput>, IDataFlowSource<TOutput>, IDataFlowSource, IDataFlowDestination<TInput>, IDataFlowDestination, IDataFlowComponent, ILoggableTask
Type Parameters
NameDescription
TInput

Type of ingoing data.

TOutput

Type of outgoing data.

Constructors

ChatBatchTransformation()

Declaration
    public ChatBatchTransformation()

ChatBatchTransformation(IChatClient)

Declaration
    public ChatBatchTransformation(IChatClient chatClient)
Parameters
TypeNameDescription
IChatClientchatClient

ChatBatchTransformation(IChatClient, int)

Declaration
    public ChatBatchTransformation(IChatClient chatClient, int batchSize)
Parameters
TypeNameDescription
IChatClientchatClient
intbatchSize

Properties

BatchSize

The number of rows sent to the chat client in one request. Default is 10.

Declaration
    public int BatchSize { get; set; }
Property Value
TypeDescription
int

ChatClient

Chat client created by the caller, for example from OpenAI or Azure OpenAI.

Declaration
    public IChatClient ChatClient { get; set; }
Property Value
TypeDescription
IChatClient

ChatOptions

Optional chat options such as model or temperature. These options are not modified. If no response format is set, a suitable one is added automatically.

Declaration
    public ChatOptions ChatOptions { get; set; }
Property Value
TypeDescription
ChatOptions

RequireSameItemCount

If true, the response must contain exactly one item per input row, otherwise an exception is thrown. Default is false, so the chat client may return more or fewer items than the batch contains.

Declaration
    public bool RequireSameItemCount { get; set; }
Property Value
TypeDescription
bool

SourceBlock

SourceBlock from the underlying TPL.Dataflow which is used as output buffer for the component.

Declaration
    public override ISourceBlock<TOutput> SourceBlock { get; }
Property Value
TypeDescription
ISourceBlock<TOutput>
Overrides

SystemPrompt

Optional system prompt sent as a system message.

Declaration
    public string SystemPrompt { get; set; }
Property Value
TypeDescription
string

TargetBlock

TargetBlock from the underlying TPL.Dataflow which is used as input buffer for the component.

Declaration
    public override ITargetBlock<TInput> TargetBlock { get; }
Property Value
TypeDescription
ITargetBlock<TInput>
Overrides

UserPrompt

Optional user prompt sent in front of the serialized batch.

Declaration
    public string UserPrompt { get; set; }
Property Value
TypeDescription
string

Methods

CheckParameter()

Declaration
    protected override void CheckParameter()
Overrides

CleanUpOnFaulted(Exception)

Declaration
    protected override void CleanUpOnFaulted(Exception e)
Parameters
TypeNameDescription
Exceptione
Overrides

CleanUpOnSuccess()

Declaration
    protected override void CleanUpOnSuccess()
Overrides

CompleteBuffer()

Declaration
    protected override void CompleteBuffer()
Overrides

FaultBuffer(Exception)

Declaration
    protected override void FaultBuffer(Exception e)
Parameters
TypeNameDescription
Exceptione
Overrides

InitComponent()

Declaration
    protected override void InitComponent()
Overrides

Reset()

Declaration
    protected override void Reset()
Overrides

Implements