ChatLLMHandler

ChatLLM. ChatLLMHandler

new ChatLLMHandler()

Source:

Members

context_trees_map :Map.<string, Map.<Model, ContextTree>>

Source:
Type:
  • Map.<string, Map.<Model, ContextTree>>

logger :logger

Source:
Type:
  • logger

Methods

_createContextTree(chat_id, model)

Description:
  • Creates context tree for specified chat and model if needed

Source:
Parameters:
Name Type Description
chat_id string
model Model

_findContextTree(chat_id, message_id) → {ContextTree|undefined}

Description:
  • Find tree by chat and message_id

Source:
Parameters:
Name Type Description
chat_id string
message_id string
Returns:
Type
ContextTree | undefined

_getChatTrees(chat_id) → {Array.<ContextTree>}

Description:
  • Get array of trees associated with chat

Source:
Parameters:
Name Type Description
chat_id string
Returns:
Type
Array.<ContextTree>

_getContextTree(chat_id) → {ContextTree}

Description:
  • Get a context tree fitting the specified arguments

Source:
Parameters:
Name Type Description
chat_id string
Object
Returns:
Type
ContextTree

(async) _replyFromContext(interaction, context, context_tree, prev_message_id) → {Promise.<CommandResponse>}

Description:
  • Makes an OpenAI API request with provided context and returnes response as text

Source:
Parameters:
Name Type Description
interaction TelegramInteraction
context Array.<NodeMessage>
context_tree ContextTree
prev_message_id string
Returns:
Type
Promise.<CommandResponse>

(async) _sendDirectResponse(interaction, context, context_tree, prev_message_id) → {Promise}

Description:
  • Proxy to ChatLLM._replyFromContext when answering to direct message or reply

Source:
Parameters:
Name Type Description
interaction TelegramInteraction
context Array.<NodeMessage>
context_tree ContextTree
prev_message_id string
Returns:
Type
Promise

_transferContextBranch(message_id, source_context_tree, destination_context_tree)

Description:
  • Move branch from one tree to another

Source:
Parameters:
Name Type Description
message_id string
source_context_tree ContextTree
destination_context_tree ContextTree

(async) answerQuestion(interaction) → {Promise}

Description:
  • Answer request received by DM

Source:
Parameters:
Name Type Description
interaction TelegramInteraction
Returns:
Type
Promise

(async) answerReply(interaction) → {Promise}

Description:
  • Answer request received via reply

Source:
Parameters:
Name Type Description
interaction TelegramInteraction
Returns:
Type
Promise

(async) handleAdjustSystemPrompt(context) → {ComplexContent}

Description:
  • Change the system prompt for the chat's context trees

Source:
Parameters:
Name Type Description
context TelegramInteraction
Returns:
Type
ComplexContent

(async) handleAnswerCommand(interaction_context, interaction, model) → {Promise}

Description:
  • Respond with ChatLLM response based on provided model, content of the replied message and/or text provided with the command

Source:
Parameters:
Name Type Description
interaction_context GrammyContext
interaction TelegramInteraction
model Model
Returns:
Type
Promise

(async) handleContextRequest(interaction) → {CommandResponse}

Description:
  • Respond with file containing context of the message

Source:
Parameters:
Name Type Description
interaction GrammyContext
Returns:
Type
CommandResponse

(async) handleModeledAnswerCommand(model, context, interaction) → {Promise}

Description:
  • Proxy to handleAnswerCommand, mainly used to specify model

Source:
Parameters:
Name Type Description
model Model
context GrammyContext
interaction TelegramInteraction
Returns:
Type
Promise

(async) handleTreeRequest(interaction) → {CommandResponse}

Description:
  • Respond with file containing context trees of the chat

Source:
Parameters:
Name Type Description
interaction GrammyContext
Returns:
Type
CommandResponse