Table of Contents

Method Submit

Namespace
LMKit.FunctionCalling
Assembly
LM-Kit.NET.dll

Submit(string, CancellationToken)

Synchronously submits a natural language prompt and returns the result of the function invocation.

public FunctionCallResult Submit(string prompt, CancellationToken cancellationToken = default)

Parameters

prompt string

The natural language prompt provided by the user.

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

FunctionCallResult

A FunctionCallResult containing the result of the invoked function.

Examples

using LMKit.Model;
using LMKit.FunctionCalling;
using System;

LM model = LM.LoadFromModelID("llama-3.2-1b");
using var functionCall = new SingleFunctionCall(model);
functionCall.ImportFunctions<Calculator>();

// Submit a natural language prompt
var result = functionCall.Submit("Calculate the sum of 15 and 27");

Console.WriteLine($"Selected function: {result.FunctionName}");
Console.WriteLine($"Confidence: {result.Confidence:P1}");
Console.WriteLine($"Result: {result.Result}");

Exceptions

ArgumentNullException

Thrown when the provided prompt argument is null or empty.

OperationCanceledException

Thrown when the operation is cancelled based on the CancellationToken.