以编程方式从文本和文档中提取关键信息。 在 JavaScript 中使用大型语言模型(LLM)生成简洁、信息丰富的摘要,以捕获文本的含义。 软件文本摘要的应用是多种多样的. 文本摘要可用于提供有关当前事件的最新信息。 通过将文本摘要功能集成到您的软件中,您不仅可以提高生产力,还可以通过尽快访问重要数据来改善决策。
Aspose.Words和大型语言模型之间的交互是建立在REST体系结构上的. 这种方法在您的 Node.js via .NET 应用程序和各种AI服务之间提供可靠和安全的通信。 要设置身份验证,您需要指定您的私有API密钥和提供所需模型的AI服务的endpoint(OpenAiModel, GoogleAiModel, AnthropicAiModel). 有关支持的LLM类型的完整列表,请参阅API Reference。
立即体验 JavaScript 智能文本处理的未来!
npm install @aspose/words
复制
const aw = require('@aspose/words');
const doc = new aw.Document("Document.docx");
const apiKey = process.env.API_KEY;
// 使用 OpenAI 或 Google 生成式语言模型。
const model = aw.AI.AiModel.createGpt4OMini();
model.setApiKey(apiKey);
const options = new aw.AI.SummarizeOptions();
options.summaryLength = aw.AI.SummaryLength.Short;
const summary = model.summarize(doc, options);
summary.save("Output.docx");
const aw = require('@aspose/words');
const doc = new aw.Document("Document.docx");
// Pass an empty string if the self-hosted model does not require an API key.
const model = new CustomAiModel("my-model-24b", "https://your-server.com/v1");
model.setApiKey("");
const options = new aw.AI.SummarizeOptions();
options.summaryLength = aw.AI.SummaryLength.Short;
const summary = model.summarize(doc, options);
summary.save("Output.docx");
class CustomAiModel extends aw.AI.OpenAiModel {
constructor(name, url) {
super(name);
this._url = url;
}
get url() {
return this._url;
}
}
We host our Node.js via .Net packages in NPM repositories. Please follow the step-by-step instructions on how to install "Aspose.Words for Node.js via .NET" to your developer environment.
This package is compatible with Node.js 14.17.0 or higher.