Skip to main content

@fluidframework/tree-agent Package

A library for creating AI agents to interact with a https://fluidframework.com/docs/data-structures/tree/.

Interfaces

InterfaceAlertsDescription
ContextAlphaThe context object available to generated code when editing a tree.
EditResultAlphaA result from an edit attempt via the edit(js) function.
ExecuteSemanticEditingOptionsAlphaOptions for executeSemanticEditing(model, tree, prompt, options).
LoggerAlphaLogger interface for logging events from a SharedTreeSemanticAgent.
SemanticAgentOptionsAlphaOptions used to parameterize the creation of a SharedTreeSemanticAgent.
SharedTreeChatModelAlphaA plugin interface that handles queries from a SharedTreeSemanticAgent.
SharedTreeChatQueryDeprecated, AlphaA query from a user to a SharedTreeSemanticAgent.
TreeAgentAlphaAn agent that can analyze and edit a SharedTree.
TreeAgentAssistantMessageAlphaAn assistant message containing the model's text response (when no tool call is made).
TreeAgentOptionsAlphaOptions for creating a tree agent via createTreeAgent(model, tree, options).
TreeAgentSystemMessageAlphaA system message providing context to the model.
TreeAgentToolCallMessageAlphaAn assistant message requesting a tool call (e.g. to edit the tree).
TreeAgentToolResultMessageAlphaA tool result message containing the outcome of a tool invocation.
TreeAgentUserMessageAlphaA user message containing a query or instruction.

Classes

ClassAlertsModifiersDescription
PropertyDefAlphaA property definition class that describes the structure of the property
SharedTreeSemanticAgentAlphasealedAn agent that uses a SharedTreeChatModel to interact with a SharedTree.

Types

TypeAliasAlertsDescription
AsynchronousEditorAlphaAn asynchronous function that executes a string of JavaScript code to perform an edit within a SharedTreeSemanticAgent.
BindableSchemaAlphaA type that represents an object schema class.
SynchronousEditorAlphaA synchronous function that executes a string of JavaScript code to perform an edit within a SharedTreeSemanticAgent.
TreeAgentChatMessageAlphaA role-tagged message in a tree agent conversation.
TreeAgentChatResponseAlphaA response from a SharedTreeChatModel after invoking it with a message history.
TreeViewAlphaA SharedTree view for use by a SharedTreeSemanticAgent.
ViewOrTreeAlphaA value that is either a TreeView or a subtree within a TreeView.

Functions

FunctionAlertsReturn TypeDescription
createContext(tree)AlphaContext<TSchema>Creates a Context for the given subtree.
createTreeAgent(model, tree, options)AlphaTreeAgentCreates an agent that can analyze and edit a SharedTree.
executeSemanticEditing(model, tree, prompt, options)AlphaPromise<string>Executes semantic editing on a tree.

Variables

VariableAlertsModifiersTypeDescription
llmDefaultAlphareadonlyunique symbolInclude this property in a field's schema metadata to indicate that the field's value should be generated via a provided function rather than by the LLM.
typeFactoryAlphareadonly{ instanceOf<T extends TreeNodeSchemaClass>(schema: T): TypeFactoryInstanceOf; string(): import("@fluidframework/type-factory/internal").TypeFactoryString; number(): import("@fluidframework/type-factory/internal").TypeFactoryNumber; boolean(): import("@fluidframework/type-factory/internal").TypeFactoryBoolean; date(): import("@fluidframework/type-factory/internal").TypeFactoryDate; void(): import("@fluidframework/type-factory/internal").TypeFactoryVoid; undefined(): import("@fluidframework/type-factory/internal").TypeFactoryUndefined; null(): import("@fluidframework/type-factory/internal").TypeFactoryNull; unknown(): import("@fluidframework/type-factory/internal").TypeFactoryUnknown; array(element: import("@fluidframework/type-factory/internal").TypeFactoryType): import("@fluidframework/type-factory/internal").TypeFactoryArray; promise(innerType: import("@fluidframework/type-factory/internal").TypeFactoryType): import("@fluidframework/type-factory/internal").TypeFactoryPromise; object(shape: Record<string, import("@fluidframework/type-factory/internal").TypeFactoryType>): import("@fluidframework/type-factory/internal").TypeFactoryObject; record(keyType: import("@fluidframework/type-factory/internal").TypeFactoryType, valueType: import("@fluidframework/type-factory/internal").TypeFactoryType): import("@fluidframework/type-factory/internal").TypeFactoryRecord; map(keyType: import("@fluidframework/type-factory/internal").TypeFactoryType, valueType: import("@fluidframework/type-factory/internal").TypeFactoryType): import("@fluidframework/type-factory/internal").TypeFactoryMap; tuple(items: readonly import("@fluidframework/type-factory/internal").TypeFactoryType[], rest?: import("@fluidframework/type-factory/internal").TypeFactoryType | undefined): import("@fluidframework/type-factory/internal").TypeFactoryTuple; union(options: readonly import("@fluidframework/type-factory/internal").TypeFactoryType[]): import("@fluidframework/type-factory/internal").TypeFactoryUnion; intersection(types: readonly import("@fluidframework/type-factory/internal").TypeFactoryType[]): import("@fluidframework/type-factory/internal").TypeFactoryIntersection; literal(value: string | number | boolean): import("@fluidframework/type-factory/internal").TypeFactoryLiteral; optional(innerType: import("@fluidframework/type-factory/internal").TypeFactoryType): import("@fluidframework/type-factory/internal").TypeFactoryOptional; readonly(innerType: import("@fluidframework/type-factory/internal").TypeFactoryType): import("@fluidframework/type-factory/internal").TypeFactoryReadonly; function(parameters: readonly import("@fluidframework/type-factory/internal").TypeFactoryFunctionParameter[], returnType: import("@fluidframework/type-factory/internal").TypeFactoryType, restParameter?: import("@fluidframework/type-factory/internal").TypeFactoryFunctionParameter | undefined): import("@fluidframework/type-factory/internal").TypeFactoryFunction; }Namespace containing type factory functions.

Function Details

createContext

Creates a Context for the given subtree.

This API is provided as an alpha preview and may change without notice.

To use, import via @fluidframework/tree-agent/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function createContext<TSchema extends ImplicitFieldSchema>(tree: ViewOrTree<TSchema>): Context<TSchema>;
Type Parameters
ParameterConstraintDescription
TSchemaImplicitFieldSchema

Parameters

ParameterTypeDescription
treeViewOrTree<TSchema>

Returns

Return type: Context<TSchema>

createTreeAgent

Creates an agent that can analyze and edit a SharedTree.

This API is provided as an alpha preview and may change without notice.

To use, import via @fluidframework/tree-agent/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function createTreeAgent<TSchema extends ImplicitFieldSchema>(model: SharedTreeChatModel, tree: ViewOrTree<TSchema>, options?: TreeAgentOptions<TSchema>): TreeAgent;
Type Parameters
ParameterConstraintDescription
TSchemaImplicitFieldSchema

Parameters

ParameterModifiersTypeDescription
modelSharedTreeChatModelThe chat model. Must implement invoke(history) and have editToolName set.
treeViewOrTree<TSchema>The tree or subtree to edit.
optionsoptionalTreeAgentOptions<TSchema>Optional configuration.

Returns

A TreeAgent.

Return type: TreeAgent

executeSemanticEditing

Executes semantic editing on a tree.

This API is provided as an alpha preview and may change without notice.

To use, import via @fluidframework/tree-agent/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function executeSemanticEditing<TSchema extends ImplicitFieldSchema>(model: SharedTreeChatModel, tree: ViewOrTree<TSchema>, prompt: string, options?: ExecuteSemanticEditingOptions<TSchema>): Promise<string>;
Type Parameters
ParameterConstraintDescription
TSchemaImplicitFieldSchema

Parameters

ParameterModifiersTypeDescription
modelSharedTreeChatModelThe chat model. Must implement invoke(history) and have editToolName set.
treeViewOrTree<TSchema>The tree or subtree to edit.
promptstringThe user's edit instruction.
optionsoptionalExecuteSemanticEditingOptions<TSchema>Optional configuration.

Returns

The model's text response.

Return type: Promise<string>

Variable Details

llmDefault

Include this property in a field's schema metadata to indicate that the field's value should be generated via a provided function rather than by the LLM.

This API is provided as an alpha preview and may change without notice.

To use, import via @fluidframework/tree-agent/alpha.

For more information about our API support guarantees, see here.

Signature

llmDefault: unique symbol

Type: unique symbol

Example

class Object extends schemaFactory.object("Object", {
created: sf.required(sf.number, {
custom: {
// The LLM will ignore this field, and instead it will be populated with the result of the function
[llmDefault]: () => Date.now(),
},
}),
}) {};

typeFactory

Namespace containing type factory functions.

This API is provided as an alpha preview and may change without notice.

To use, import via @fluidframework/tree-agent/alpha.

For more information about our API support guarantees, see here.

Signature

typeFactory: {
instanceOf<T extends TreeNodeSchemaClass>(schema: T): TypeFactoryInstanceOf;
string(): import("@fluidframework/type-factory/internal").TypeFactoryString;
number(): import("@fluidframework/type-factory/internal").TypeFactoryNumber;
boolean(): import("@fluidframework/type-factory/internal").TypeFactoryBoolean;
date(): import("@fluidframework/type-factory/internal").TypeFactoryDate;
void(): import("@fluidframework/type-factory/internal").TypeFactoryVoid;
undefined(): import("@fluidframework/type-factory/internal").TypeFactoryUndefined;
null(): import("@fluidframework/type-factory/internal").TypeFactoryNull;
unknown(): import("@fluidframework/type-factory/internal").TypeFactoryUnknown;
array(element: import("@fluidframework/type-factory/internal").TypeFactoryType): import("@fluidframework/type-factory/internal").TypeFactoryArray;
promise(innerType: import("@fluidframework/type-factory/internal").TypeFactoryType): import("@fluidframework/type-factory/internal").TypeFactoryPromise;
object(shape: Record<string, import("@fluidframework/type-factory/internal").TypeFactoryType>): import("@fluidframework/type-factory/internal").TypeFactoryObject;
record(keyType: import("@fluidframework/type-factory/internal").TypeFactoryType, valueType: import("@fluidframework/type-factory/internal").TypeFactoryType): import("@fluidframework/type-factory/internal").TypeFactoryRecord;
map(keyType: import("@fluidframework/type-factory/internal").TypeFactoryType, valueType: import("@fluidframework/type-factory/internal").TypeFactoryType): import("@fluidframework/type-factory/internal").TypeFactoryMap;
tuple(items: readonly import("@fluidframework/type-factory/internal").TypeFactoryType[], rest?: import("@fluidframework/type-factory/internal").TypeFactoryType | undefined): import("@fluidframework/type-factory/internal").TypeFactoryTuple;
union(options: readonly import("@fluidframework/type-factory/internal").TypeFactoryType[]): import("@fluidframework/type-factory/internal").TypeFactoryUnion;
intersection(types: readonly import("@fluidframework/type-factory/internal").TypeFactoryType[]): import("@fluidframework/type-factory/internal").TypeFactoryIntersection;
literal(value: string | number | boolean): import("@fluidframework/type-factory/internal").TypeFactoryLiteral;
optional(innerType: import("@fluidframework/type-factory/internal").TypeFactoryType): import("@fluidframework/type-factory/internal").TypeFactoryOptional;
readonly(innerType: import("@fluidframework/type-factory/internal").TypeFactoryType): import("@fluidframework/type-factory/internal").TypeFactoryReadonly;
function(parameters: readonly import("@fluidframework/type-factory/internal").TypeFactoryFunctionParameter[], returnType: import("@fluidframework/type-factory/internal").TypeFactoryType, restParameter?: import("@fluidframework/type-factory/internal").TypeFactoryFunctionParameter | undefined): import("@fluidframework/type-factory/internal").TypeFactoryFunction;
}

Type: { instanceOf<T extends TreeNodeSchemaClass>(schema: T): TypeFactoryInstanceOf; string(): import("@fluidframework/type-factory/internal").TypeFactoryString; number(): import("@fluidframework/type-factory/internal").TypeFactoryNumber; boolean(): import("@fluidframework/type-factory/internal").TypeFactoryBoolean; date(): import("@fluidframework/type-factory/internal").TypeFactoryDate; void(): import("@fluidframework/type-factory/internal").TypeFactoryVoid; undefined(): import("@fluidframework/type-factory/internal").TypeFactoryUndefined; null(): import("@fluidframework/type-factory/internal").TypeFactoryNull; unknown(): import("@fluidframework/type-factory/internal").TypeFactoryUnknown; array(element: import("@fluidframework/type-factory/internal").TypeFactoryType): import("@fluidframework/type-factory/internal").TypeFactoryArray; promise(innerType: import("@fluidframework/type-factory/internal").TypeFactoryType): import("@fluidframework/type-factory/internal").TypeFactoryPromise; object(shape: Record<string, import("@fluidframework/type-factory/internal").TypeFactoryType>): import("@fluidframework/type-factory/internal").TypeFactoryObject; record(keyType: import("@fluidframework/type-factory/internal").TypeFactoryType, valueType: import("@fluidframework/type-factory/internal").TypeFactoryType): import("@fluidframework/type-factory/internal").TypeFactoryRecord; map(keyType: import("@fluidframework/type-factory/internal").TypeFactoryType, valueType: import("@fluidframework/type-factory/internal").TypeFactoryType): import("@fluidframework/type-factory/internal").TypeFactoryMap; tuple(items: readonly import("@fluidframework/type-factory/internal").TypeFactoryType[], rest?: import("@fluidframework/type-factory/internal").TypeFactoryType | undefined): import("@fluidframework/type-factory/internal").TypeFactoryTuple; union(options: readonly import("@fluidframework/type-factory/internal").TypeFactoryType[]): import("@fluidframework/type-factory/internal").TypeFactoryUnion; intersection(types: readonly import("@fluidframework/type-factory/internal").TypeFactoryType[]): import("@fluidframework/type-factory/internal").TypeFactoryIntersection; literal(value: string | number | boolean): import("@fluidframework/type-factory/internal").TypeFactoryLiteral; optional(innerType: import("@fluidframework/type-factory/internal").TypeFactoryType): import("@fluidframework/type-factory/internal").TypeFactoryOptional; readonly(innerType: import("@fluidframework/type-factory/internal").TypeFactoryType): import("@fluidframework/type-factory/internal").TypeFactoryReadonly; function(parameters: readonly import("@fluidframework/type-factory/internal").TypeFactoryFunctionParameter[], returnType: import("@fluidframework/type-factory/internal").TypeFactoryType, restParameter?: import("@fluidframework/type-factory/internal").TypeFactoryFunctionParameter | undefined): import("@fluidframework/type-factory/internal").TypeFactoryFunction; }