Class PdfChatGpt
Nom dels espais: Aspose.Pdf.Plugins Assemblea: Aspose.PDF.dll
Representa el plugin PdfChatGpt.
public sealed class PdfChatGpt : IPlugin, IDisposable
Inheritance
Implements
Membres heretats
object.GetType() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
L’exemple demostra com utilitzar el plugin PdfChatGpt afegint missatges a la sol·licitud.
using (var plugin = new PdfChatGpt())
{
var options = new PdfChatGptRequestOptions();
options.AddOutput(new FileDataSource("PdfChatGPT_output.pdf")); // Add the output file path.
options.ApiKey = "Your API key."; // You need to provide the key to access the API.
options.MaxTokens = 1000; // The maximum number of tokens to generate in the chat completion.
// Add the request messages.
options.Messages.Add(new Message
{
Content = "You are a helpful assistant.",
Role = Role.System
});
options.Messages.Add(new Message
{
Content = "What is the biggest pizza diameter ever made?",
Role = Role.User
});
// Process the request.
var result = await plugin.ProcessAsync(options);
var fileResultPath = result.ResultCollection[0].Data;
var chatCompletionObject = result.ResultCollection[1].Data as ChatCompletion; // The ChatGPT API chat completion object.
}
L’exemple demostra com utilitzar el plugin PdfChatGpt afegint un missatge a la sol·licitud.
using (var plugin = new PdfChatGpt())
{
var options = new PdfChatGptRequestOptions();
options.AddOutput(new FileDataSource("PdfChatGPT_output.pdf")); // Add the output file path.
options.ApiKey = "Your API key."; // You need to provide the key to access the API.
options.MaxTokens = 1000; // The maximum number of tokens to generate in the chat completion.
// Add the request message.
// In this case, the system message with Content = "You are a helpful assistant." is added by default.
// The role of the query message is "user" by default.
options.Query = "What is the lowest temperature recorded on the Earth?";
// Process the request.
var result = await plugin.ProcessAsync(options);
var fileResultPath = result.ResultCollection[0].Data;
var chatCompletionObject = result.ResultCollection[1].Data as ChatCompletion; // The ChatGPT API chat completion object.
}
L’exemple demostra com utilitzar el plugin PdfChatGpt mitjançant l’addició de fitxers(s) com a font de missatge(s).
using (var plugin = new PdfChatGpt())
{
var options = new PdfChatGptRequestOptions();
options.AddOutput(new FileDataSource("PdfChatGPT_output.pdf")); // Add the output file path.
// Add the PDF text source.
// In case of multiple sources, the text from each document will be added to the request message collection
// as a separate message with the role "user".
options.AddInput(new FileDataSource("TextSource.pdf"));
options.ApiKey = "Your API key."; // You need to provide the key to access the API.
options.MaxTokens = 1000; // The maximum number of tokens to generate in the chat completion.
// Add the request message.
// In this case, the system message with Content = "You are a helpful assistant." is added by default.
// The role of the query message is "user" by default.
options.Query = "How many letters in the provided text?";
// Process the request.
var result = await plugin.ProcessAsync(options);
var fileResultPath = result.ResultCollection[0].Data;
var chatCompletionObject = result.ResultCollection[1].Data as ChatCompletion; // The ChatGPT API chat completion object.
}
Remarks
L’objecte Aspose.Pdf.Plugins.PdfChatGpt s’utilitza per enviar sol·licituds a ChatGPT directamento afegint fonts de fitxer PDF i guardant la resposta a la font de sortida.
Constructors
PdfChatGpt()
public PdfChatGpt()
Methods
Dispose()
Implementació de IDisposable. De fet, no és necessari per a PdfChatGpt.
public void Dispose()
Process(Opcions IPlugin)
El mètode no té versió sincronitzada. utilitzeu el mètode ProcessAsync en lloc.
public ResultContainer Process(IPluginOptions options)
Parameters
options
IPluginOptions
Un objecte d’opcions que conté instruccions per al PdfChatGpt.
Returns
Exceptions
ProcessAsync(Opcions IPlugin)
Comença el processament PdfChatGpt amb els paràmetres especificats.
public Task<resultcontainer> ProcessAsync(IPluginOptions options)
Parameters
options
IPluginOptions
Un objecte d’opcions que conté instruccions per al PdfChatGpt.
Returns
Task < ResultContainer >
L’objecte de la tasca representa l’operació asíncrona.
Exceptions
SetCancellationToken(CancellationToken)
Introdueix el token de cancel·laci.
public void SetCancellationToken(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationToken
El token de cancel·laci.