Class AIClientAbstract

Abstract class for AI clients.

Hierarchy

Constructors

Properties

_apiKey: string

API key used by the AI client.

_model: string

Model used by the AI client.

Methods

  • Assembles the chat history based on user inputs, graph changes, and actions taken.

    Parameters

    • userPrompt: string

      user prompt

    • graph: Graph

      current state of the graph

    • history: HistoryElement[]

      array containing the history of actions taken by the user and the graph states

    • historyIndex: number

      index to start from in the history

    • Optional maxLookBack: number

      maximum number of past tasks to include in the output

    Returns Message[]

    assembled chat history with 'user' and 'assistant' roles, and the content for each

  • Returns an object containing a token count placeholder and the token limit for the AI model.

    Parameters

    • message: string

      message to count tokens

    Returns TokenInfo

    object with a token count and token limit

  • Transforms the history of actions taken by the user and the graph states.

    Parameters

    • history: Message[]

      array containing the history of actions taken by the user and the graph states

    Returns Message[]

    Transformed history

  • Makes a request to the AI model to generate a Q&A response to the user's input of how to use the tool.

    Parameters

    • query: string

      user's query

    Returns Promise<string>

    promise that resolves with the response from the AI model

  • Sends a user prompt to the AI model and returns a difference object between the current graph and the new graph.

    Parameters

    • userPrompt: string

      user prompt

    • params: {
          config: Config;
          graph: Graph;
          history: HistoryElement[];
          historyIndex: number;
      }

      options for the query including current state of the graph, an array containing the history of actions taken by the user and the graph states, index to start from in the history, and configuration options for the query

    Returns Promise<string>

    promise that resolves with the difference between the current graph and the new graph

  • Request completion from the AI model for the given messages.

    Parameters

    • messages: Message[]

      array representing the user's messages

    Returns Promise<string>

    promise that resolves with the response from the AI model

Generated using TypeDoc