gpt.askSends a message to the ChatGPT neural network and returns its response.
Signature: gpt.ask(model string, text string, temperature float = 0.7, useContext bool = false, maxTokens int = 0, timeout int = 0) string
Arguments:
model — the name of the neural network model.text — a request to the neural network.temperature — a number from 0 to 1 that determines the degree of reliability and variability of responses (0 — maximum reliability, 1 — maximum variability).useContext — determines whether to use the previous conversation context.maxTokens — the maximum number of tokens in the neural network response (if greater than zero). If the value is less than or equal to zero, the restriction does not apply.timeout — the time limit for executing the request in seconds (if greater than zero) .Return value: Neural network response as a string.
Note:
If context is used (useContext = true), the current message is stored in the $“context.{MODEL}” variable list, and all previous messages will be passed to the request along with it.
If useContext = false, the current message is not added to the list.
The message list ($“context.{MODEL}”) is available for editing.
Example of use:
$answer = gpt.ask(“gpt-4-1106-preview”, “Is there life on Mars?”, 0.5, true, 500, 10) // $answer will contain the neural network's answer to the specified question.
gpt.createThreadCreates a conversation session with the GPT assistant.
Signature: gpt.createThread() string
Arguments: No arguments.
Return value: Chat session ID.
Example of use:
$threadId = gpt.createThread()
gpt.deleteThreadDeletes a conversation session with the GPT assistant.
Signature: gpt.deleteThread(threadId string)
Arguments: threadId — chat session ID.
Return value: None.
Example usage:
gpt.deleteThread($threadId)
gpt.assistSends a message to the GPT assistant and returns its response.
Signature: gpt.assist(assistantId string, threadId string, messages string|Collection, model string = ‘’, instructions string = ‘’, additionalInstructions string = ‘’, temperature float = 0.7, maxTokens int = 0, timeout int = 0) string
Arguments:
assistantId — assistant ID.threadId — chat session ID obtained via gpt.createThread().messages — request to the neural network: a string or collection of messages.model — the name of the model replacing the model specified when creating the assistant.instructions — instructions for the assistant, replacing the original ones.additionalInstructions — additional instructions added to the main ones.temperature — a number from 0 to 1 that determines the degree of reliability and variability of responses.maxTokens — the maximum number of tokens in a response (if greater than zero).timeout — the time limit for executing a request in seconds (if greater than zero).Return value: The neural network's response as a string.
Example of use:
$answer = gpt.assist($assistId, $threadId, “Is there life on Mars?”, “gpt-3.5-turbo-1106”, ‘’, “”, 0.5, 500, 10) // $answer will contain the neural network's response to the specified question.
gpt.askReasoningSends a message to the ChatGPT neural network and returns its response. It is used with reasoning models (for example, o1, o3, o4-mini, o3-mini, etc.).
Signature: gpt.askReasoning(model string, text string, effort string = 'medium', useContext bool = false, maxTokens int = 0, timeout int = 0) string
Arguments:
model is the name of the neural network model.text is a request to the neural network.effort — limits the cost of reasoning. Supported values are: low, medium, high.useContext — determines whether to use the previous conversation context.maxTokens is the maximum number of tokens in the neural network response (if greater than zero). If the value is less than or equal to zero, the restriction is not applied.timeout — the time limit for query execution in seconds (if greater than zero).Return value: The neural network response as a string.
Usage example:
$answer = gpt.askReasoning("o3-mini", "Is there life on Mars?", "medium", false, 500, 10)