Interface ConversationPluginDefinitionBase

The base definition of a conversation plugin without output.

Hierarchy

  • ConversationPluginDefinitionBase

Properties

onChatCompletion?: ((message) => void | Promise<void>)

Type declaration

    • (message): void | Promise<void>
    • Tap into an assistant message instance during a chat completion before it is added to the history.

      Parameters

      • message: Message

        The assistant message instance

      Returns void | Promise<void>

      Remarks

      Keep in mind that the message passed to this method is not necessarily a standard chat completion. It could be a function call too. Additionnaly, the message could be streamed or not, so message content may not yet be available when this method is called.

onFunctionPrompt?: ((message) => void | Promise<void>)

Type declaration

    • (message): void | Promise<void>
    • Tap into a function message instance.

      Parameters

      • message: Message

        The function message instance

      Returns void | Promise<void>

onFunctionPromptError?: ((error) => void | Promise<void>)

Type declaration

    • (error): void | Promise<void>
    • Called when an error is thrown during a function prompt. This can be useful to clean up your plugin's state.

      Parameters

      • error: unknown

        The error that was thrown during a function prompt

      Returns void | Promise<void>

      Remarks

      Errors thrown during this method will have no effect. This is to ensure all plugins implementing this method are called.

onModeration?: ((message) => void | Promise<void>)

Type declaration

    • (message): void | Promise<void>
    • Tap into a message that was moderated.

      Parameters

      • message: Message

        The message that was moderated, with the message.flags property populated.

      Returns void | Promise<void>

onPostInit?: (() => void)

Type declaration

    • (): void
    • Called after all plugins have been initialized.

      Returns void

      Remarks

      This could potentially be used to interop with other plugins.

onUserPrompt?: ((message) => void | Promise<void>)

Type declaration

    • (message): void | Promise<void>
    • Tap into a user message instance created during prompt.

      Parameters

      • message: Message

        The user message instance

      Returns void | Promise<void>

onUserPromptError?: ((error) => void | Promise<void>)

Type declaration

    • (error): void | Promise<void>
    • Called when an error is thrown during a user prompt. This can be useful to clean up your plugin's state.

      Parameters

      • error: unknown

        The error that was thrown during a user prompt

      Returns void | Promise<void>

      Remarks

      Errors thrown during this method will have no effect. This is to ensure all plugins implementing this method are called.

transformConversationCallableFunctionsJson?: ((json) => {
    functions?: ({ name: string; id?: string | undefined; description?: string | undefined; parameters?: { type: "object"; title?: string | undefined; description?: string | undefined; default?: any; examples?: any[] | undefined; ... 10 more ...; additionalProperties?: boolean | ... 1 more ... | undefined; } | undefined; })[];
})

Type declaration

    • (json): {
          functions?: ({ name: string; id?: string | undefined; description?: string | undefined; parameters?: { type: "object"; title?: string | undefined; description?: string | undefined; default?: any; examples?: any[] | undefined; ... 10 more ...; additionalProperties?: boolean | ... 1 more ... | undefined; } | undefined; })[];
      }
    • Transform the ConversationCallableFunctionsModel returned by the ConversationCallableFunctions.toJSON method. Note that this is the model of the ConversationCallableFunctions class, not the CallableFunction class.

      Must return a valid ConversationCallableFunctionsModel. Model is validated using the conversationCallableFunctionsSchema at the end of all transformations.

      Parameters

      • json: {
            functions?: ({ name: string; id?: string | undefined; description?: string | undefined; parameters?: { type: "object"; title?: string | undefined; description?: string | undefined; default?: any; examples?: any[] | undefined; ... 10 more ...; additionalProperties?: boolean | ... 1 more ... | undefined; } | undefined; })[];
        }

        The current ConversationCallableFunctionsModel that was generated by the library (or previous plugins)

        • Optional functions?: ({ name: string; id?: string | undefined; description?: string | undefined; parameters?: { type: "object"; title?: string | undefined; description?: string | undefined; default?: any; examples?: any[] | undefined; ... 10 more ...; additionalProperties?: boolean | ... 1 more ... | undefined; } | undefined; })[]

      Returns {
          functions?: ({ name: string; id?: string | undefined; description?: string | undefined; parameters?: { type: "object"; title?: string | undefined; description?: string | undefined; default?: any; examples?: any[] | undefined; ... 10 more ...; additionalProperties?: boolean | ... 1 more ... | undefined; } | undefined; })[];
      }

      The new state of the ConversationCallableFunctionsModel to be returned by the ConversationCallableFunctions.toJSON method.

      • Optional functions?: ({ name: string; id?: string | undefined; description?: string | undefined; parameters?: { type: "object"; title?: string | undefined; description?: string | undefined; default?: any; examples?: any[] | undefined; ... 10 more ...; additionalProperties?: boolean | ... 1 more ... | undefined; } | undefined; })[]
transformConversationConfigJson?: ((json) => {
    apiKey?: string;
    context?: string;
    disableModeration?: boolean | "soft";
    dry?: boolean;
    frequency_penalty?: number;
    function_call?: "none" | "auto" | ({ name: string; });
    logit_bias?: Record<string, number>;
    max_tokens?: number;
    model?: string;
    presence_penalty?: number;
    stop?: null | string | string[];
    stream?: boolean;
    temperature?: number;
    top_p?: number;
    user?: string;
})

Type declaration

    • (json): {
          apiKey?: string;
          context?: string;
          disableModeration?: boolean | "soft";
          dry?: boolean;
          frequency_penalty?: number;
          function_call?: "none" | "auto" | ({ name: string; });
          logit_bias?: Record<string, number>;
          max_tokens?: number;
          model?: string;
          presence_penalty?: number;
          stop?: null | string | string[];
          stream?: boolean;
          temperature?: number;
          top_p?: number;
          user?: string;
      }
    • Transform the ConversationConfigModel returned by the ConversationConfig.toJSON method.

      Must return a valid ConversationConfigModel. Model is validated using the conversationConfigSchema at the end of all transformations.

      Parameters

      • json: {
            apiKey?: string;
            context?: string;
            disableModeration?: boolean | "soft";
            dry?: boolean;
            frequency_penalty?: number;
            function_call?: "none" | "auto" | ({ name: string; });
            logit_bias?: Record<string, number>;
            max_tokens?: number;
            model?: string;
            presence_penalty?: number;
            stop?: null | string | string[];
            stream?: boolean;
            temperature?: number;
            top_p?: number;
            user?: string;
        }

        The current ConversationConfigModel that was generated by the library (or previous plugins)

        • Optional apiKey?: string
        • Optional context?: string
        • Optional disableModeration?: boolean | "soft"
        • Optional dry?: boolean
        • Optional frequency_penalty?: number
        • Optional function_call?: "none" | "auto" | ({ name: string; })
        • Optional logit_bias?: Record<string, number>
        • Optional max_tokens?: number
        • Optional model?: string
        • Optional presence_penalty?: number
        • Optional stop?: null | string | string[]
        • Optional stream?: boolean
        • Optional temperature?: number
        • Optional top_p?: number
        • Optional user?: string

      Returns {
          apiKey?: string;
          context?: string;
          disableModeration?: boolean | "soft";
          dry?: boolean;
          frequency_penalty?: number;
          function_call?: "none" | "auto" | ({ name: string; });
          logit_bias?: Record<string, number>;
          max_tokens?: number;
          model?: string;
          presence_penalty?: number;
          stop?: null | string | string[];
          stream?: boolean;
          temperature?: number;
          top_p?: number;
          user?: string;
      }

      The new state of the ConversationConfigModel to be returned by the ConversationConfig.toJSON method.

      • Optional apiKey?: string
      • Optional context?: string
      • Optional disableModeration?: boolean | "soft"
      • Optional dry?: boolean
      • Optional frequency_penalty?: number
      • Optional function_call?: "none" | "auto" | ({ name: string; })
      • Optional logit_bias?: Record<string, number>
      • Optional max_tokens?: number
      • Optional model?: string
      • Optional presence_penalty?: number
      • Optional stop?: null | string | string[]
      • Optional stream?: boolean
      • Optional temperature?: number
      • Optional top_p?: number
      • Optional user?: string
transformConversationHistoryJson?: ((json) => {
    messages?: ({ role: "function" | "user" | "assistant" | "system"; content: string | null; id?: string | undefined; name?: string | undefined; function_call?: { name: string; arguments: Record<string, any>; } | undefined; model?: string | undefined; flags?: string[] | ... 1 more ... | undefined; })[];
})

Type declaration

    • (json): {
          messages?: ({ role: "function" | "user" | "assistant" | "system"; content: string | null; id?: string | undefined; name?: string | undefined; function_call?: { name: string; arguments: Record<string, any>; } | undefined; model?: string | undefined; flags?: string[] | ... 1 more ... | undefined; })[];
      }
    • Transform the ConversationHistoryModel returned by the ConversationHistory.toJSON method.

      Must return a valid ConversationHistoryModel. Model is validated using the conversationHistorySchema at the end of all transformations.

      Parameters

      • json: {
            messages?: ({ role: "function" | "user" | "assistant" | "system"; content: string | null; id?: string | undefined; name?: string | undefined; function_call?: { name: string; arguments: Record<string, any>; } | undefined; model?: string | undefined; flags?: string[] | ... 1 more ... | undefined; })[];
        }

        The current ConversationHistoryModel that was generated by the library (or previous plugins)

        • Optional messages?: ({ role: "function" | "user" | "assistant" | "system"; content: string | null; id?: string | undefined; name?: string | undefined; function_call?: { name: string; arguments: Record<string, any>; } | undefined; model?: string | undefined; flags?: string[] | ... 1 more ... | undefined; })[]

      Returns {
          messages?: ({ role: "function" | "user" | "assistant" | "system"; content: string | null; id?: string | undefined; name?: string | undefined; function_call?: { name: string; arguments: Record<string, any>; } | undefined; model?: string | undefined; flags?: string[] | ... 1 more ... | undefined; })[];
      }

      The new state of the ConversationHistoryModel to be returned by the ConversationHistory.toJSON method.

      • Optional messages?: ({ role: "function" | "user" | "assistant" | "system"; content: string | null; id?: string | undefined; name?: string | undefined; function_call?: { name: string; arguments: Record<string, any>; } | undefined; model?: string | undefined; flags?: string[] | ... 1 more ... | undefined; })[]
transformConversationJson?: ((json) => {
    callableFunctions?: { functions?: { name: string; id?: string | undefined; description?: string | undefined; parameters?: { type: "object"; title?: string | undefined; description?: string | undefined; default?: any; ... 11 more ...; additionalProperties?: boolean | ... 1 more ... | undefined; } | undefined; }[] | undefined; };
    config?: { context?: string | undefined; dry?: boolean | undefined; disableModeration?: boolean | "soft" | undefined; apiKey?: string | undefined; model?: string | undefined; temperature?: number | undefined; ... 8 more ...; function_call?: "none" | ... 2 more ... | undefined; };
    history?: { messages?: { role: "function" | "user" | "assistant" | "system"; content: string | null; id?: string | undefined; name?: string | undefined; function_call?: { name: string; arguments: Record<...>; } | undefined; model?: string | undefined; flags?: string[] | ... 1 more ... | undefined; }[] | undefined; };
    id?: string;
    pluginsData?: Record<string, any>;
    requestOptions?: { headers?: Record<string, string> | undefined; proxy?: { host: string; port?: number | undefined; protocol?: "http" | "https" | undefined; auth?: { username: string; password: string; } | undefined; } | undefined; };
})

Type declaration

    • (json): {
          callableFunctions?: { functions?: { name: string; id?: string | undefined; description?: string | undefined; parameters?: { type: "object"; title?: string | undefined; description?: string | undefined; default?: any; ... 11 more ...; additionalProperties?: boolean | ... 1 more ... | undefined; } | undefined; }[] | undefined; };
          config?: { context?: string | undefined; dry?: boolean | undefined; disableModeration?: boolean | "soft" | undefined; apiKey?: string | undefined; model?: string | undefined; temperature?: number | undefined; ... 8 more ...; function_call?: "none" | ... 2 more ... | undefined; };
          history?: { messages?: { role: "function" | "user" | "assistant" | "system"; content: string | null; id?: string | undefined; name?: string | undefined; function_call?: { name: string; arguments: Record<...>; } | undefined; model?: string | undefined; flags?: string[] | ... 1 more ... | undefined; }[] | undefined; };
          id?: string;
          pluginsData?: Record<string, any>;
          requestOptions?: { headers?: Record<string, string> | undefined; proxy?: { host: string; port?: number | undefined; protocol?: "http" | "https" | undefined; auth?: { username: string; password: string; } | undefined; } | undefined; };
      }
    • Transform the ConversationModel returned by the Conversation.toJSON method.

      Must return a valid ConversationModel. Model is validated using the conversationSchema at the end of all transformations.

      Parameters

      • json: {
            callableFunctions?: { functions?: { name: string; id?: string | undefined; description?: string | undefined; parameters?: { type: "object"; title?: string | undefined; description?: string | undefined; default?: any; ... 11 more ...; additionalProperties?: boolean | ... 1 more ... | undefined; } | undefined; }[] | undefined; };
            config?: { context?: string | undefined; dry?: boolean | undefined; disableModeration?: boolean | "soft" | undefined; apiKey?: string | undefined; model?: string | undefined; temperature?: number | undefined; ... 8 more ...; function_call?: "none" | ... 2 more ... | undefined; };
            history?: { messages?: { role: "function" | "user" | "assistant" | "system"; content: string | null; id?: string | undefined; name?: string | undefined; function_call?: { name: string; arguments: Record<...>; } | undefined; model?: string | undefined; flags?: string[] | ... 1 more ... | undefined; }[] | undefined; };
            id?: string;
            pluginsData?: Record<string, any>;
            requestOptions?: { headers?: Record<string, string> | undefined; proxy?: { host: string; port?: number | undefined; protocol?: "http" | "https" | undefined; auth?: { username: string; password: string; } | undefined; } | undefined; };
        }

        The current ConversationModel that was generated by the library (or previous plugins)

        • Optional callableFunctions?: { functions?: { name: string; id?: string | undefined; description?: string | undefined; parameters?: { type: "object"; title?: string | undefined; description?: string | undefined; default?: any; ... 11 more ...; additionalProperties?: boolean | ... 1 more ... | undefined; } | undefined; }[] | undefined; }
        • Optional config?: { context?: string | undefined; dry?: boolean | undefined; disableModeration?: boolean | "soft" | undefined; apiKey?: string | undefined; model?: string | undefined; temperature?: number | undefined; ... 8 more ...; function_call?: "none" | ... 2 more ... | undefined; }
        • Optional history?: { messages?: { role: "function" | "user" | "assistant" | "system"; content: string | null; id?: string | undefined; name?: string | undefined; function_call?: { name: string; arguments: Record<...>; } | undefined; model?: string | undefined; flags?: string[] | ... 1 more ... | undefined; }[] | undefined; }
        • Optional id?: string
        • Optional pluginsData?: Record<string, any>
        • Optional requestOptions?: { headers?: Record<string, string> | undefined; proxy?: { host: string; port?: number | undefined; protocol?: "http" | "https" | undefined; auth?: { username: string; password: string; } | undefined; } | undefined; }

      Returns {
          callableFunctions?: { functions?: { name: string; id?: string | undefined; description?: string | undefined; parameters?: { type: "object"; title?: string | undefined; description?: string | undefined; default?: any; ... 11 more ...; additionalProperties?: boolean | ... 1 more ... | undefined; } | undefined; }[] | undefined; };
          config?: { context?: string | undefined; dry?: boolean | undefined; disableModeration?: boolean | "soft" | undefined; apiKey?: string | undefined; model?: string | undefined; temperature?: number | undefined; ... 8 more ...; function_call?: "none" | ... 2 more ... | undefined; };
          history?: { messages?: { role: "function" | "user" | "assistant" | "system"; content: string | null; id?: string | undefined; name?: string | undefined; function_call?: { name: string; arguments: Record<...>; } | undefined; model?: string | undefined; flags?: string[] | ... 1 more ... | undefined; }[] | undefined; };
          id?: string;
          pluginsData?: Record<string, any>;
          requestOptions?: { headers?: Record<string, string> | undefined; proxy?: { host: string; port?: number | undefined; protocol?: "http" | "https" | undefined; auth?: { username: string; password: string; } | undefined; } | undefined; };
      }

      The new state of the ConversationModel to be returned by the Conversation.toJSON method.

      • Optional callableFunctions?: { functions?: { name: string; id?: string | undefined; description?: string | undefined; parameters?: { type: "object"; title?: string | undefined; description?: string | undefined; default?: any; ... 11 more ...; additionalProperties?: boolean | ... 1 more ... | undefined; } | undefined; }[] | undefined; }
      • Optional config?: { context?: string | undefined; dry?: boolean | undefined; disableModeration?: boolean | "soft" | undefined; apiKey?: string | undefined; model?: string | undefined; temperature?: number | undefined; ... 8 more ...; function_call?: "none" | ... 2 more ... | undefined; }
      • Optional history?: { messages?: { role: "function" | "user" | "assistant" | "system"; content: string | null; id?: string | undefined; name?: string | undefined; function_call?: { name: string; arguments: Record<...>; } | undefined; model?: string | undefined; flags?: string[] | ... 1 more ... | undefined; }[] | undefined; }
      • Optional id?: string
      • Optional pluginsData?: Record<string, any>
      • Optional requestOptions?: { headers?: Record<string, string> | undefined; proxy?: { host: string; port?: number | undefined; protocol?: "http" | "https" | undefined; auth?: { username: string; password: string; } | undefined; } | undefined; }

      Remarks

      You should not modify the pluginsData property of the ConversationModel in this method. Use the getPluginData method instead to prevent conflicts with other plugins.

transformConversationRequestOptionsJson?: ((json) => {
    headers?: Record<string, string>;
    proxy?: { host: string; port?: number | undefined; protocol?: "http" | "https" | undefined; auth?: { username: string; password: string; } | undefined; };
})

Type declaration

    • (json): {
          headers?: Record<string, string>;
          proxy?: { host: string; port?: number | undefined; protocol?: "http" | "https" | undefined; auth?: { username: string; password: string; } | undefined; };
      }
    • Transform the ConversationRequestOptionsModel returned by the ConversationRequestOptions.toJSON method.

      Must return a valid ConversationRequestOptionsModel. Model is validated using the conversationRequestOptionsSchema at the end of all transformations.

      Parameters

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

        The current ConversationRequestOptionsModel that was generated by the library (or previous plugins)

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

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

      The new state of the ConversationRequestOptionsModel to be returned by the ConversationRequestOptions.toJSON method.

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

Type declaration

    • (result): any
    • Transform the function prompt result before it is stringified.

      Parameters

      • result: any

        The result of the function generated by the client code

      Returns any

      The new result. Keep in mind this result is later stringified (using JSON.stringify). Your result must be serializable.

Generated using TypeDoc