import { ChatOpenAI } from "langchain/chat_models/openai";
import { HumanMessage } from "langchain/schema";
(async () => {
const chat = new ChatOpenAI(
{
maxTokens: 25,
streaming: true,
},
{ basePath: "https://you-app-url.app/v1" }, //replace with my own url
);
const response = await chat.call([new HumanMessage("Tell me a joke.")], {
callbacks: [
{
handleLLMNewToken(token: string) {
console.log({ token });
},
},
],
});
console.log(response);
})();
设置 streaming:true后,不起作用。