new ContextTree(system_prompt, model)
- Source:
Parameters:
| Name | Type | Description | 
|---|---|---|
| system_prompt | string | undefined | |
| model | Model | undefined | 
Members
nodes :Map.<string, ContextNode>
- Source:
Type:
- Map.<string, ContextNode>
root_node :ContextNode
- Source:
Type:
- ContextNode
Methods
appendBranch(node, branch)
- Description:
- Append branch to the tree 
 
- Source:
Parameters:
| Name | Type | Description | 
|---|---|---|
| node | ContextNode | leading node (that should be attached to root) | 
| branch | Map.<string, ContextNode> | map of nodes including node | 
appendNode()
- Description:
- Creates new node and appends to the tree either by the prev_message_id or to the root node 
 
- Source:
Parameters:
| Type | Description | 
|---|---|
| Object | 
checkNodeExists() → {boolean}
- Description:
- Checks if node exists either by node's message_id or provided message_id 
 
- Source:
Parameters:
| Type | Description | 
|---|---|
| Object | 
Returns:
- Type
- boolean
detachBranch(message_id) → {Object}
- Description:
- Detach the branch where node with specified message_id exists, returns the child of a root node and a map of nodes 
 
- Source:
Parameters:
| Name | Type | Description | 
|---|---|---|
| message_id | string | 
Returns:
- Type
- Object
detachNode(message_id) → {ContextNode|undefined}
- Description:
- Get node by id and remove it from tree (relinks node's children to node's parent) 
 
- Source:
Parameters:
| Name | Type | Description | 
|---|---|---|
| message_id | string | 
Returns:
- Type
- ContextNode | undefined
getContext(message_id, limit) → {Array.<NodeMessage>}
- Description:
- Gets the context of the message as an array 
 
- Source:
Parameters:
| Name | Type | Default | Description | 
|---|---|---|---|
| message_id | string | ||
| limit | number | 30 | 
Returns:
- Type
- Array.<NodeMessage>
getModelType() → {'text'|'vision'}
- Description:
- Get type of the model used for the tree 
 
- Source:
Returns:
- Type
- 'text' | 'vision'
getNode(message_id) → {ContextNode|undefined}
- Description:
- Get Node by message_id 
 
- Source:
Parameters:
| Name | Type | Description | 
|---|---|---|
| message_id | string | 
Returns:
- Type
- ContextNode | undefined
getProvider() → {Provider}
- Description:
- Get provider for model in the tree 
 
- Source:
Returns:
- Type
- Provider
getRawContext(message_id) → {Array.<NodeRawData>}
- Description:
- Gets the raw context of the message as an array 
 
- Source:
Parameters:
| Name | Type | Default | Description | 
|---|---|---|---|
| message_id | string | undefined | null | 
Returns:
- Type
- Array.<NodeRawData>