Table of Contents

Cloud AI Tool Sets

A tool set is a component that carries a group of ready-declared function-calling tools. Drop one next to a TTMSMCPCloudAI, point its AI property at that component, and the model can call every tool in the set from the next request onwards — with no tool declaration, no parameter schema, and no handler of your own. TMS AI Studio ships four of them: TTMSMCPCloudAILogger writes results to a dialog, the console, or a file; TTMSMCPCloudAIFileSystem lists, reads, writes, copies, and moves files; TTMSMCPCloudAIDataSet exposes an open dataset through a TDataSource; and TTMSMCPCloudAIEmail sends mail over SMTP and reads it back over POP3. They all derive from TTMSMCPCloudAIToolSet, so your own sets attach the same way.

Documentation

Start here Use when
Getting started You want one tool set attached and working quickly.
User guide You want task-oriented chapters grouped by feature area.
API reference You want exact class, property, method, and event contracts.
Release notes You want the version history for this component.

Key classes

Class Role
TTMSMCPCloudAIToolSet The base class: an AI property that registers the set, and a Tools collection that holds its declarations.
TTMSMCPCloudAILogger Three logging tools — message dialog, console, and a timestamped log file named by LogFileName.
TTMSMCPCloudAIFileSystem Eight file system tools: list files and folders, read, write, append, create a folder, copy, and move.
TTMSMCPCloudAIDataSet Twelve dataset tools reaching an open dataset through the DataSource property: schema, navigation, read, add, modify, and locate.
TTMSMCPCloudAIEmail Three mail tools plus the SMTP and POP3 settings they use, and public methods for connecting and reading messages from code.
TTMSMCPCloudAITool One tool inside a set: name, description, parameters, Enabled, and the handler that answers it.
TTMSMCPCloudAITools The collection a set exposes as Tools; also what the component merges at request time.
TTMSMCPCloudAI The component a tool set attaches to, and the one that actually issues the request.

Minimal example

procedure TForm1.FormCreate(Sender: TObject);
begin
  { AI is a TTMSMCPCloudAI on the form. The keys were written once with
    AI.APIKeys.SaveToFile, so no secret is present in this source. }
  AI.APIKeys.LoadFromFile(KeyStoreFileName, KeyStorePassword);
  AI.Service := aiOpenAI;
  AI.OnExecuted := AIExecuted;

  { One component, and the model can now list folders, read text files,
    write them, copy and move them. No tool declaration of your own. }
  FFiles := TTMSMCPCloudAIFileSystem.Create(Self);
  FFiles.AI := AI;
end;

procedure TForm1.btnAskClick(Sender: TObject);
begin
  if AI.Busy then
    Exit;

  AI.SystemRole.Text :=
    'Answer only from the file system tools. Never invent a file name.';
  AI.Context.Text :=
    'Which log files are in the reports folder, and what does the newest ' +
    'one end with?';
  AI.Execute;
end;

procedure TForm1.AIExecuted(Sender: TObject; AResponse: TTMSMCPCloudAIResponse;
  AHttpStatusCode: Integer; AHttpResult: string);
begin
  if Assigned(AResponse) then
    memoAnswer.Lines.Text := AResponse.Content.Text
  else
    memoAnswer.Lines.Text := Format('Request failed (%d): %s',
      [AHttpStatusCode, AHttpResult]);
end;

API map

Role Types
Base class TTMSMCPCloudAIToolSet
Shipped tool sets TTMSMCPCloudAILogger, TTMSMCPCloudAIFileSystem, TTMSMCPCloudAIDataSet, TTMSMCPCloudAIEmail
Tool declarations TTMSMCPCloudAITool, TTMSMCPCloudAITools, TTMSMCPCloudAIParameter, TTMSMCPCloudAIParameters
Parameter typing TTMSMCPCloudAIParameterType, TTMSMCPCloudAIFormat, TTMSMCPCloudAIToolType
Handler callback TTMSMCPCloudAIToolExecuteEvent
Host component TTMSMCPCloudAI, TTMSMCPCloudAIResponse

Guides

Guide Covers
Attaching tool sets The AI property and what registration does, how a set's tools reach the model, inspecting and disabling individual tools, moving a set between components, teardown order, and extending a shipped set with a tool of your own.
The four shipped tool sets Every tool in the logger, file system, dataset, and email sets — its arguments, what it returns, the properties it reads, and the ordering each set expects.

See Also