Documentation

openai_gpt_functions.php

Table of Contents

Functions

openai_gpt_update_field()  : bool|array<string|int, mixed>
Send the new field value or image to the OpenAI API in order to update the linked field
openai_gpt_generate_completions()  : string
Call OpenAI compatibile APIs
openai_gpt_get_dependent_fields()  : array<string|int, mixed>
Return array of resource type field refs for a given openai_gpt_input_field value.
openai_gpt_get_configured_fields()  : array<string|int, mixed>
Return an array of resource type field refs for all AI configured fields
openai_gpt_get_tokens_used()  : int
Return a count of tokens used by GPT during the number of days passed as a parameter.
openai_gpt_get_provider()  : string
Return the configured AI provider handles the remote override.

Functions

openai_gpt_update_field()

Send the new field value or image to the OpenAI API in order to update the linked field

openai_gpt_update_field(int|array<string|int, mixed> $resources, array<string|int, mixed> $target_field, array<string|int, mixed> $values[, string $file = "" ]) : bool|array<string|int, mixed>
Parameters
$resources : int|array<string|int, mixed>

Resource ID or array of resource IDS

$target_field : array<string|int, mixed>

Target metadata field array from get_resource_type_field()

$values : array<string|int, mixed>

Array of strings from the field currently being processed

$file : string = ""

Path to image file. If provided will use this file instead of metadata values

Return values
bool|array<string|int, mixed>

Array indicating success/failure True if update successful, false if invalid field or no data returned

openai_gpt_generate_completions()

Call OpenAI compatibile APIs

openai_gpt_generate_completions(string $endpoint, string $api_key, string $model, array<string|int, mixed> $messages[, float $temperature = 0 ][, int $max_tokens = 2048 ]) : string

Refer to https://beta.openai.com/docs/api-reference for detailed explanation

Parameters
$endpoint : string

API endpoint

$api_key : string

API key

$model : string

Model name e.g. "text-davinci-003"

$messages : array<string|int, mixed>

Array of prompt messages to generate response from API. See https://platform.openai.com/docs/guides/chat/introduction for more information

$temperature : float = 0

Value between 0 and 1 - higher values means model will take more risks. Default 0.

$max_tokens : int = 2048

The maximum number of completions to generate, default 2048

Return values
string

The first API response text output

openai_gpt_get_dependent_fields()

Return array of resource type field refs for a given openai_gpt_input_field value.

openai_gpt_get_dependent_fields(int $field) : array<string|int, mixed>
Parameters
$field : int

ID of GPT input field.

Return values
array<string|int, mixed>

openai_gpt_get_configured_fields()

Return an array of resource type field refs for all AI configured fields

openai_gpt_get_configured_fields() : array<string|int, mixed>
Return values
array<string|int, mixed>

Array field references for all AI configured fields

openai_gpt_get_tokens_used()

Return a count of tokens used by GPT during the number of days passed as a parameter.

openai_gpt_get_tokens_used(int $days) : int

Defaults to using 30 days if 0 or less is passed.

Parameters
$days : int
Return values
int

Count of tokens used in $days days

openai_gpt_get_provider()

Return the configured AI provider handles the remote override.

openai_gpt_get_provider() : string
Return values
string

Currently configured AI provider

On this page

Search results