สรุป DOCX ใน JavaScript

สรุป DOCX ด้วย JavaScript.

การบูรณาการอย่างไร้รอยต่อกับโมเดลภาษาใหญ่ เช่น OpenAI, Claude และ Gemini ให้ความสามารถในการประมวลผล DOCX ด้วย AI อย่างครอบคลุมสำหรับแอปพลิเคชัน Node.js

ดูข้อมูลโค้ด

สรุปเอกสาร DOCX ใน JavaScript

ดึงข้อมูลสำคัญจากไฟล์ DOCX อย่างอัตโนมัติโดยใช้โมเดลภาษาใหญ่ (LLM) ใน JavaScript. Aspose.Words สำหรับ Node.js via .NET อ่านเอกสาร DOCX ของคุณและสร้างสรุปสั้นที่สื่อความหมายสำคัญของข้อความต้นฉบับ.

วิธีสรุปไฟล์ DOCX ใน JavaScript

  • โหลดไฟล์ DOCX เข้าไปในอ็อบเจ็กต์ Document
  • เลือกโมเดล AI — OpenAI (GPT-4o), Google (Gemini) หรือ Claude
  • เรียกใช้เมธอด Summarize พร้อมการตั้งค่าความยาวแบบเลือกได้
  • บันทึกสรุปที่ได้เป็นรูปแบบ DOCX, PDF หรือรูปแบบที่รองรับอื่นใด

ตัวอย่างต่อไปนี้แสดงวิธีสรุปเอกสาร DOCX ใน JavaScript:

ตัวอย่างโค้ดใน JavaScript สำหรับสรุป DOCX
เลือกรูปแบบเป้าหมายจากรายการ
รันโค้ด
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;
    }
}
รันโค้ด

วิธีสรุป DOCX ใน JavaScript

  1. ติดตั้ง Aspose.Words for Node.js via .NET.
  2. เพิ่มการอ้างอิงไลบรารี (นำเข้าไลบรารี) ไปยังโครงการ JavaScript ของคุณ.
  3. เปิดไฟล์ต้นฉบับใน JavaScript.
  4. เรียกใช้เมธอด โดยส่งเอกสารของคุณพร้อมพารามิเตอร์ SummarizeOptions
  5. เมื่อเสร็จสิ้น คุณจะได้รับสรุปเอกสารสั้น ๆ ที่สามารถบันทึกเป็นไฟล์ใหม่ในรูปแบบที่ต้องการ

ไลบรารี Node.js via .NET สำหรับสรุปไฟล์ DOCX

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 Product Updates

รับจดหมายข่าวและข้อเสนอรายเดือนที่ส่งตรงถึงกล่องจดหมายของคุณ