async function main()

in packages/nodejs/ask.js [27:44]


async function main(args) {
    const key = args.OPENAI_API_KEY || process.env.OPENAI_API_KEY
    const host = args.OPENAI_API_HOST || process.env.OPENAI_API_HOST
    const model = "gpt-35-turbo"
    const AI = new OpenAIClient(host, new AzureKeyCredential(key))
    const input = args.input || ""
    let answer = "Please provide an input parameter."
    if (input != "") {
        //const { id, created, choices, usage } =
        const request = [
            { role: "system", content: "You are a helpful assistant." },
            { role: "user", content: input },
        ]
        const response = await AI.getChatCompletions(model, request);
        answer = response.choices[0].message.content
    }
    return { body: answer }
}