Wrapper around Baidu ERNIE large language models that use the Chat endpoint.

To use you should have the BAIDU_API_KEY and BAIDU_SECRET_KEY environment variable set.

Example

const ernieTurbo = new ChatBaiduWenxin({
baiduApiKey: "YOUR-API-KEY",
baiduSecretKey: "YOUR-SECRET-KEY",
});

const ernie = new ChatBaiduWenxin({
modelName: "ERNIE-Bot",
temperature: 1,
baiduApiKey: "YOUR-API-KEY",
baiduSecretKey: "YOUR-SECRET-KEY",
});

const messages = [new HumanMessage("Hello")];

let res = await ernieTurbo.call(messages);

res = await ernie.call(messages);

Hierarchy

  • BaseChatModel
    • ChatBaiduWenxin

Implements

  • BaiduWenxinChatInput

Constructors

  • Parameters

    • Optional fields: Partial<BaiduWenxinChatInput> & BaseLanguageModelParams

    Returns ChatBaiduWenxin

Properties

accessToken: string
apiUrl: string
modelName: string = "ERNIE-Bot-turbo"
streaming: boolean = false
baiduApiKey?: string
baiduSecretKey?: string
penaltyScore?: number
prefixMessages?: WenxinMessage[]
temperature?: number
topP?: number
userId?: string

Accessors

  • get callKeys(): string[]
  • Returns string[]

Methods

  • Method that retrieves the access token for making requests to the Baidu API.

    Parameters

    • Optional options: Omit<BaseLanguageModelCallOptions, never>

      Optional parsed call options.

    Returns Promise<any>

    The access token for making requests to the Baidu API.

  • Get the identifying parameters for the model

    Returns {
        model_name: string;
        penalty_score?: number;
        stream?: boolean;
        system?: string;
        temperature?: number;
        top_p?: number;
        user_id?: string;
    }

    • model_name: string
    • Optional penalty_score?: number
    • Optional stream?: boolean
    • Optional system?: string
    • Optional temperature?: number
    • Optional top_p?: number
    • Optional user_id?: string
  • Get the parameters used to invoke the model

    Returns Omit<ChatCompletionRequest, "messages">

Generated using TypeDoc