AI

Input, Output, and Execution

Methods for providing input to the AI model, specifying where results go, executing the task, and reacting to the AI response - including live form-wired input and output.

Methods for providing input to the AI model, specifying where results go, executing the task, and reacting to the AI response - including live form-wired input and output.

WithInputFrom sets the data to send to the AI model - accepts strings, grids, GPALFile, GPALDatabase, GPALInput, or GPALTextArea. WithLiveInputFrom(control, debounce) wires a GPALInput or GPALTextArea directly: the AI reruns automatically after the user stops typing, using a debounce window (default 500ms). WithOutputTo receives the result - accepts IGPALGrid<string>, GPALTextArea, GPALRichTextBox, GPALDatabase, or GPALFile; pointing it at a form control lets AI output appear inside the form without extra wiring. WithStatusTo(GPALStatusStrip) routes status messages to a status strip while the AI is working. Execute() runs the AI task with the current configuration. CallAfterAIResponse registers a delegate that fires after the AI returns its response, receiving the response text for custom post-processing.

Examples

GPAL Fluent: High-level fluent C# API

//WithLiveInputFrom replaces WithInputFrom when the source is a live form control - it calls WithInputFrom internally and also wires the debounce timer, so no extra setup is needed. WithOutputTo pointing at a GPALTextArea or GPALRichTextBox writes the AI response directly into the control. WithStatusTo is optional but recommended for live pipelines so the user knows the AI is working.

// Static pipeline: input from a string, output to a grid var results = GPAL.Grid.ToGPALObject(); GPAL.Ai .WithCredentials(aiCreds) .WithProvider(AIProviderType.Anthropic) .WithTask(AITask.Summarization) .WithInputFrom(documentText) .WithOutputTo(out results) .Execute(); // Live form pipeline: AI reruns as the user types // output streams into a TextArea, status shows in the strip GPAL.Ai .WithCredentials(aiCreds) .WithProvider(AIProviderType.OpenAI) .WithTask(AITask.Summarization) .WithLiveInputFrom(inputControl, debounceMilliseconds: 800) .WithOutputTo(outputTextArea) .WithStatusTo(statusStrip) .Execute();