OpenAI
createOpenAiLlmCall
This is a function that calls an OpenAI LLM. You can configure almost any parameter that can be configured in the Create chat completion OpenAI endpoint.
Arguments
Identifier which will be passed into the callback.
An object that contains all configuration parameters for the LLM call. See below for details on the OpenAiRequest object.
Returns
An internal counter of the oracle, which is incremented on every call.
OpenAiRequest object
The OpenAiRequest
object (see source in IOracle.sol) has the following fields:
The identifier for the model, gpt-4-turbo
, gpt-4-turbo-preview
or gpt-3.5-turbo-1106
.
An integer between -20 and 20, mapped to a float between -2.0 and 2.0; values greater than 20 are treated as null.
A JSON string representing logit bias or an empty string if none.
The maximum number of tokens to generate, with 0 indicating null.
An integer between -20 and 20, mapped to a float between -2.0 and 2.0; values greater than 20 are treated as null.
A JSON string specifying the format of the response or an empty string if default.
A seed for the random number generator, with 0 indicating null.
A string specifying stop sequences, or an empty string to indicate null.
A temperature setting for randomness, with values from 0 to 20; values greater than 20 indicate null.
Controls diversity via nucleus sampling, with values from 0 to 100 percent; values greater than 100 indicate null.
A JSON list of tools in OpenAI format, or an empty string for null, where names must match supported tools.
Specifies tool selection strategy, with values “none”, “auto”, or an empty string which defaults to “auto” on OpenAI’s side.
Identifier for the user making the request.
onOracleOpenAiLlmResponse
Called when the result of an LLM call, created with createOpenAiLlmCall
, is available.
Arguments
The identifier you passed into the createOpenAiLlmCall
method.
The result of the LLM call. See below for details on the OpenAiResponse object.
An error message. Contains an empty string if there was no error, and a description of the error otherwise.
OpenAiResponse object
The OpenAiResponse
object (see source in ChatOracle.sol) has the following fields, most of which map directly to the fields in the OpenAI API response:
Unique identifier for the completion, generated by OpenAI.
The model output. Either this field or functionArguments
and functionName
will be populated, depending on whether the output is a normal message or a function call.
Name of the function invoked, if any.
Arguments passed to the function, if any, as a JSON string. For format details, refer to the specific function documentation.
Timestamp of creation.
The model name used for generation.
Identifier for the system generating the completion.
Type of the object, always chat.completion
.
Number of tokens generated in the completion.
Number of tokens in the prompt.
Total number of tokens, including both prompt and completion.