Class ChatCompletionServiceInternal

Encapsulates the logic for sending requests to the OpenAI API for the Create Chat Completion endpoint.

This class is used internally by the library and is not meant to be instantiated by consumers of the library.

Hierarchy

  • ChatCompletionService

Constructors

Properties

pluginService: ConversationPluginService<ConversationPlugin<string, any, any>[]>

Methods

  • Gets the assistant's response given the current messages stored in the conversation's history, moderates it if moderation is enabled, and adds it to the conversation's history.

    Parameters

    • Optional options: PromptOptions

      Additional options to pass to the Create Chat Completion API endpoint. This overrides the config passed to the constructor.

    • Optional requestOptions: {
          headers?: Record<string, string>;
          proxy?: { host: string; port?: number | undefined; protocol?: "http" | "https" | undefined; auth?: { username: string; password: string; } | undefined; };
      }

      Additional options to pass for the HTTP request. This overrides the config passed to the constructor.

      • Optional headers?: Record<string, string>
      • Optional proxy?: { host: string; port?: number | undefined; protocol?: "http" | "https" | undefined; auth?: { username: string; password: string; } | undefined; }

    Returns Promise<Message>

    The assistant's response as a Message instance.

  • Internal

    Should not be used directly by library consumers. Use getChatCompletionResponse from the Conversation class instead.

    Parameters

    • options: PromptOptions = {}
    • requestOptions: {
          headers?: Record<string, string>;
          proxy?: { host: string; port?: number | undefined; protocol?: "http" | "https" | undefined; auth?: { username: string; password: string; } | undefined; };
      } = {}
      • Optional headers?: Record<string, string>
      • Optional proxy?: { host: string; port?: number | undefined; protocol?: "http" | "https" | undefined; auth?: { username: string; password: string; } | undefined; }

    Returns Promise<Message>

  • Parameters

    • options: HandleChatCompletionOptions = {}
    • requestOptions: {
          headers?: Record<string, string>;
          proxy?: { host: string; port?: number | undefined; protocol?: "http" | "https" | undefined; auth?: { username: string; password: string; } | undefined; };
      } = {}
      • Optional headers?: Record<string, string>
      • Optional proxy?: { host: string; port?: number | undefined; protocol?: "http" | "https" | undefined; auth?: { username: string; password: string; } | undefined; }

    Returns Promise<Message>

  • Parameters

    • options: HandleChatCompletionOptions = {}
    • requestOptions: {
          headers?: Record<string, string>;
          proxy?: { host: string; port?: number | undefined; protocol?: "http" | "https" | undefined; auth?: { username: string; password: string; } | undefined; };
      } = {}
      • Optional headers?: Record<string, string>
      • Optional proxy?: { host: string; port?: number | undefined; protocol?: "http" | "https" | undefined; auth?: { username: string; password: string; } | undefined; }

    Returns Message

  • Internal

    Should not be used directly by library consumers. Use moderate from the Message class instead.

    Parameters

    • message: Message
    • Optional requestOptions: {
          headers?: Record<string, string>;
          proxy?: { host: string; port?: number | undefined; protocol?: "http" | "https" | undefined; auth?: { username: string; password: string; } | undefined; };
      }
      • Optional headers?: Record<string, string>
      • Optional proxy?: { host: string; port?: number | undefined; protocol?: "http" | "https" | undefined; auth?: { username: string; password: string; } | undefined; }

    Returns Promise<void>

Generated using TypeDoc