customRequest

customRequest

PREMIUM TRIAL / ADVANCED

Does a custom request to GPT.

Description
public customRequest ( $source [, array $options = array()] )

This method does a custom request to GPT.

Supported AI integrations:

  • GPT OpenAI
Parameters

source

DOCX document.

options

An array with the available options.

The possible keys and values are:

key Type Description
frequency_penalty float Default as 0.0.
max_tokens int Default as 1000. Each OpenAI model limits max tokens.
model string Default as 'text-davinci-003'.
presence_penalty float Default as 0.0.
prompt string Default as empty.
temperature float Default as 0 (set 0.5 to generate related keywords).
top_p float Default as 1.0.
url string Default as 'https://api.openai.com/v1/completions'.
Return values

array

Exceptions

Empty prompt.

Error connecting to GPT.

GPT error.

Code samples

Example #1

The resulting output looks like:

Release notes
  • phpdocx 14.0:
    • new method.