Intégration transparente avec les principaux modèles de langage tels qu'OpenAI, Claude et Gemini offre d'importantes capacités de traitement PDF basées sur l'IA pour les applications Node.js.
Extrayez les informations clés des fichiers PDF de manière programmatique à l'aide de grands modèles de langage (LLM) dans JavaScript. Aspose.Words for Node.js via .NET lit votre document PDF et produit un résumé concis qui saisit le sens essentiel du texte original.
L'exemple suivant montre comment résumer un document PDF en JavaScript :
npm install @aspose/words
Copie
const aw = require('@aspose/words');
const doc = new aw.Document("Document.docx");
const apiKey = process.env.API_KEY;
// Utilisez les modèles de langage génératifs d'OpenAI ou de 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.pdf");
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.pdf");
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.