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

Implements

  • BaiduWenxinChatInput

Constructors

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

Methods

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

    Parameters

    • Optional options: unknown

      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

Generated using TypeDoc