DataSourceItemFilter Delegate

Assembly: CodeEffects.Rule.Repository.dll
Namespace: CodeEffects.Rule.Repository

Summary

Defines the signature of a method that decides whether AI agents may read one item of a Dynamic Menu Data Source.

Syntax

public delegate bool DataSourceItemFilter(string dataSourceName, string itemId, string itemLabel);

Parameters

  • dataSourceName

    Type: System.String

    The name of the data source, as the source object declares it.

  • itemId

    Type: System.String

    The ID, or key, of the item, as text.

  • itemLabel

    Type: System.String

    The name of the item, as the data source's method returns it. It is the text people see in the menu.

Returns

Type: System.Boolean

true to let agents read the item; false to leave it out.

Remarks

An AI agent that writes a rule often has to turn a name a person used, such as "Gold tier", into the ID that the rule stores. To do this it reads the items of a data source. Assign a method of this type to the DataSourceItemFilter property of AgentSettings to narrow what agents may read: the repository calls it once for each item before it hands the item to an agent. An item for which it returns false is left out of the agent's answer and of its count.

The filter narrows what agents can read and never widens it. It applies only when AgentSettings.AgentDataSourceItems is true, which is the default. It does not affect what people see in the Rule Repository. When no filter is set, agents may read every item of every data source.

The repository calls the filter on the thread of the request, once for each item of the data source that the agent asked about, so keep it fast and free of side effects. Assign the filter to the Agents property of the configuration, as in the example below.

Example

using CodeEffects.Rule.Repository;

// Agents may read every item except the Employees items whose names start with "Exec".
DataSourceItemFilter filter = (dataSourceName, itemId, itemLabel) =>
	dataSourceName != "Employees" || !itemLabel.StartsWith("Exec");

var config = new Configuration
{
	Agents = new AgentSettings { DataSourceItemFilter = filter }
};

Ask on Stack Overflow - Yes, it's still active
Ask in GitHub Discussions

p102

l097 --

l102

p101

×