在 JavaScript 中摘要 Word、PDF、Web 文件

使用 JavaScript 進行文件摘要。

與 OpenAI、Claude 和 Gemini 等主要語言模型的無縫整合,為 Node.js 應用程式提供豐富的 AI 驅動文件處理能力。

查看代碼片段

Node.js via .NET 應用程式的智慧文本摘要

以程式設計方式從文字和文件中提取關鍵資訊。使用 JavaScript 中的大型語言模型 (LLM) 產生簡潔、資訊豐富的摘要,以捕捉文本的含義。軟體文本摘要的應用範圍廣泛且多元。文字摘要可用於提供有關當前事件的最新資訊。透過將文字摘要功能整合到您的軟體中,您不僅可以提高工作效率,還可以透過盡快存取重要數據來改善決策。.

主要特點

  • 易於使用的 API,可輕鬆與 Node.js via .NET 軟體集成
  • 能夠與各種 LLM 模型整合以滿足您的需求
  • 能夠自訂文字摘要設置
  • 支援多種文件格式

Aspose.Words 和大型語言模型之間的交互作用建構在 REST 架構之上。此方法可在您的 Node.js via .NET 應用程式和各種 AI 服務之間提供可靠且安全的通訊。要設定驗證,您需要指定您的私鑰 API 和提供您所需模型的 AI 服務的 endpoint(OpenAiModel, GoogleAiModel, AnthropicAiModel)。有關受支援的 LLM 類型的完整列表,請參閱 API Reference。.

立即體驗 JavaScript 智慧文字處理的未來!!

使用 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;
    }
}
運行代碼

如何在 JavaScript 中摘要文件

  1. 安裝 Aspose.Words for Node.js via .NET。
  2. 將函式庫參考(匯入函式庫)加入您的 JavaScript 專案。
  3. 在 JavaScript 中開啟來源檔案。
  4. 呼叫 方法,傳入文件及 SummarizeOptions 參數。
  5. 完成後,您將獲得簡潔的文件摘要,可依需求以所需格式另存為新檔案。

Node.js via .NET 函式庫,用於文件摘要

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.

System Requirements

This package is compatible with Node.js 14.17.0 or higher.

5%

訂閱 Aspose 產品更新

獲取直接發送到您的郵箱的每月通訊和優惠。

© Aspose Pty Ltd 2001-2026. 版權所有。