Print

OpenAIExecuteQuery()

The OpenAIExecuteQuery() function allows to send a prompt (question) to the OpenAI service and returns the model’s reponse.

Syntax

OpenAIExecuteQuery(question, settings);

Function arguments

  • query – (String) a prompt (question) to the OpenAI model;
  • settings – (Object) [Optional] settings for request to the OpenAI:
    • settings.SystemMessage – (String) [Optional] a system message to inform the model what it should do;
    • settings.Temperature – (Decimal) [Optional] a temperature parameter for the model. The default value is 0.3;
    • settings.MaxTokens – (Decimal) [Optional] a maximum number of tokens for the model. The default value is 2000;
    • settings.Model – (String) [Optional] the OpenAI model version (GPT4 or GPT3.5). If not provided the default model will be taken from AMODIT system settings (see [4] on the picture below);
    • settings.ExampleQuestion1 – (String) [Optional] an example question. You can add more questions by changing 1 to 2 or more;
    • settings.ExampleAnswer1 – (String) [Optional] an example answer. You can add more answers by changing 1 to 2 or more. There should be as many answers as questions.

Return value

This function returns String.
The AI’s reponse to the prompt/question.

Examples

Example 1

This code will create a poem about animals. The poem as AI’s response will be placed in the „textField1” field on the form.

settings.SystemMessage="You are the best poem writer in the world.";
settings.Model = "GPT3.5";
[textField1] = OpenAIExecuteQuery("Write a funny poem about animals and rain.", settings);

Example 2

This code will create a suggestion for an email content about the given topic from the form field named „request”. The suggestion as AI’s response will be placed in the „textField1” field on the form.

sMessage="Act as an assistant who writes polite and official emails to employees from company XYZ.";
settings.SystemMessage=sMessage;
settings.Model = "GPT3.5";
[textField1] = OpenAIExecuteQuery([request], settings);

 

Czy artykuł był pomocny?
0 na 5 gwiazdek
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we improve this article?
How Can We Improve This Article?