OpenAI Streaming Client.

This is an implementation of the OpenAIClient class, specifically for streaming completions instead of making a single completion request.

Hierarchy

Constructors

Properties

_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

  • Creates a token stream from the chat.

    Parameters

    • messages: Message[]

      an array of messages

    Returns AsyncGenerator<string, void, unknown>

    async generator that yields the tokens from the chat

  • Returns an object containing the number of tokens in a message and the token limit for the AI model.

    Parameters

    • message: string

      message to count tokens for

    Returns TokenInfo

    an object with a token count and token limit

  • 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 a completion from the AI model for the given messages.

    Parameters

    • messages: Message[]

      an array of messages

    Returns Promise<string>

    promise that resolves with the response from the AI model

  • Reconfigures the API client with a new key.

    Parameters

    • apiKey: string

      new API key to use

    Returns void

Generated using TypeDoc