Skip to main content

SharedTreeChatModel Interface

A plugin interface that handles queries from a SharedTreeSemanticAgent.

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 interface SharedTreeChatModel

Remarks

This wraps an underlying communication with an LLM and receives all necessary context from the agent for the LLM to properly analyze and edit the tree. See @fluidframework/tree-agent-langchain for a drop-in implementation based on the LangChain library.

Properties

PropertyAlertsModifiersTypeDescription
editToolNameAlphaoptionalstringThe name of the tool that the model should use to edit the tree.
nameAlphaoptionalstringA optional name of this chat model.

Methods

MethodAlertsModifiersReturn TypeDescription
appendContext(text)Deprecated, AlphaoptionalvoidAdd contextual information to the model that may be relevant to future queries.
invoke(history)AlphaoptionalPromise<TreeAgentChatResponse>Invoke the model with the given message history and return a single response.
query(message)Deprecated, AlphaoptionalPromise<string>Queries the chat model with a request from the user.

Property Details

editToolName

The name of the tool that the model should use to edit the tree.

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

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

Signature

editToolName?: string;

Type: string

Remarks

If supplied, this will be mentioned in the context provided to the model so that the underlying LLM will be encouraged to use it when a user query requires an edit. The model should "implement" the tool by registering it with the underlying LLM API. The tool should take an LLM-generated JavaScript function as input and supply it to the edit function. Instructions for generating the proper function signature and implementation will be provided by the agent via context. If not supplied, the model will not be able to edit the tree (running the edit function will fail).

name

A optional name of this chat model.

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

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

Signature

name?: string;

Type: string

Remarks

If supplied, this may be used in logging or debugging information.

Example

"gpt-5"

Method Details

appendContext

Add contextual information to the model that may be relevant to future queries.

This API is deprecated and will be removed in a future release.

Use invoke(history) instead. Context is provided via system messages in the history.

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

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

Signature

appendContext?(text: string): void;

Remarks

In practice, this may be implemented by e.g. appending a "system" message to an LLM's chat/message history. This context must be present in the context window of every query for e.g. editing to work.

Parameters

ParameterTypeDescription
textstringThe message or context to append.

invoke

Invoke the model with the given message history and return a single response.

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

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

Signature

invoke?(history: readonly TreeAgentChatMessage[]): Promise<TreeAgentChatResponse>;

Remarks

This is the stateless API. The model should not maintain any internal message history; all context is provided via the history parameter. Implementations should convert the TreeAgentChatMessage array to the underlying LLM's message format, invoke the LLM, and return either a TreeAgentToolCallMessage (if the model wants to call a tool) or a TreeAgentAssistantMessage (if the model is done).

Parameters

ParameterTypeDescription
historyreadonly TreeAgentChatMessage[]

Returns

Return type: Promise<TreeAgentChatResponse>

query

Queries the chat model with a request from the user.

This API is deprecated and will be removed in a future release.

Use invoke(history) instead. The edit loop is now managed by the agent via createTreeAgent(model, tree, options).

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

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

Signature

query?(message: SharedTreeChatQuery): Promise<string>;

Remarks

This model may simply return a text response to the query, or it may first call the edit(js) function (potentially multiple times) to modify the tree in response to the query.

Parameters

ParameterTypeDescription
messageSharedTreeChatQuery

Returns

Return type: Promise<string>