OpenAI Library MT5
- 라이브러리
- VitalDefender Inc.
- 버전: 1.0
- 활성화: 5
The following library is proposed as a means of being able to use the OpenAI API directly on the metatrader, in the simplest way possible.
For more on the library's capabilities, read the following article:
https://www.mql5.com/en/blogs/post/756098
The files needed to use the library can be found here:
In order to use the library, you must include the following Header, which you can find at the following link:
https://www.mql5.com/en/blogs/post/756108
#import "StormWaveOpenAI.ex5"
COpenAI *iOpenAI(string);
CMessages *iMessages(void);
CTools *iTools(void);
#import
This is all you need to be able to Use the library with ease.
Below is an example of how you can use the library with ease and operate with the OpenAI API
#include <StormWaveOpenAI.mqh> //--- Include the custom OpenAI header file for API integration COpenAI *client; //--- Declare a pointer to the OpenAI client CMessages *_message_; //--- Declare a pointer for handling messages //--- The OnStart function is the entry point of the script OnStart() { client = iOpenAI("YOUR_API_KEY"); //--- Initialize the OpenAI client with your API key client.start_thread(); //--- Start a new thread for the OpenAI client to operate in string completion; //--- Variable to store the API response _message_ = iMessages(); //--- Initialize the message handler string user_content = "Hi how are you?"; //--- Define the message content _message_.AddMessage(user_content, user); //--- Add the message to the handler with a user identifier //--- Call the API to generate a completion based on the provided messages completion = client.completions_create( /*model = */ "gpt-3.5-turbo-0125", //--- Specify the model to use for the completion /*messages = */ _message_, //--- Pass the messages to the API /*max_tokens = */ 300, //--- Set the maximum number of tokens to generate /*temperature = */ 1.0 //--- Set the creativity level of the response ); client.PrintResultMessage(); //--- Print the result of the API call delete _message_; //--- Clean up the message handler delete client; //--- Clean up the OpenAI client }
For further details, please feel free to contact me. I express my thanks in advance in case you decide to purchase this library. Should you encounter bugs, I would be grateful if you could contribute to the improvement of the library by privately sending me the problems you encounter so that I can make the necessary improvements.