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)AlphaoptionalvoidAdd contextual information to the model that may be relevant to future queries.
query(message)AlphaPromise<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 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.

query

Queries the chat model with a request from the user.

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>