Class PdfChatGpt

Class PdfChatGpt

Pôvodný názov: Aspose.Pdf.Plugins Spoločnosť: Aspose.PDF.dll

Predstavuje PdfChatGpt plugin.

public sealed class PdfChatGpt : IPlugin, IDisposable

Inheritance

object PdfChatGpt

Implements

IPlugin , IDisposable

Z dedičných členov

object.GetType() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

Príklad ukazuje, ako používať plugin PdfChatGpt pridaním správ do požiadavky.

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.
}

Príklad ukazuje, ako používať plugin PdfChatGpt pridaním jednej správy k žiadosti.

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.
}

Príklad ukazuje, ako používať plugin PdfChatGpt pridaním súboru(s) ako zdroj(s) správy(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

Objekt Aspose.Pdf.Plugins.PdfChatGpt sa používa na odoslanie žiadostí na ChatGPT priamoalebo pridaním zdrojov súboru PDF a uložením odpovede na zdroj výstupu.

Constructors

PdfChatGpt()

public PdfChatGpt()

Methods

Dispose()

Vykonávanie IDisposable. v skutočnosti to nie je potrebné pre PdfChatGpt.

public void Dispose()

Process(IPluginopcie)

Metóda nemá synchronickú verziu.Namiesto toho použite metódu ProcessAsync.

public ResultContainer Process(IPluginOptions options)

Parameters

options IPluginOptions

Objekt možnosti, ktorý obsahuje pokyny pre PdfChatGpt.

Returns

ResultContainer

Exceptions

NotImplementedException

ProcessAsync(IPluginopcie)

Začína sa spracovanie PdfChatGpt s špecifikovanými parametrami.

public Task<resultcontainer> ProcessAsync(IPluginOptions options)

Parameters

options IPluginOptions

Objekt možnosti, ktorý obsahuje pokyny pre PdfChatGpt.

Returns

Task < ResultContainer >

Objekt úlohy predstavuje asynchrónnu činnosť.

Exceptions

ArgumentException

InvalidOperationException

SetCancellationToken(CancellationToken)

Zadajte zrušený token.

public void SetCancellationToken(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Zrušiť token.

 Slovenčina