I have imported matlab.http.* and other HTTP packages in the startupFcn, but when other method (function) are called, it still prompts error messages showing that I didn't import them ... I have to import them in EVERY methods that will use those packages... BUT I think this approach sucks ... Anyone who can give me a simpler and reasonable way to solve this? My code is attached below...
startupFcn()
methods (Access = private)
import matlab.net.http.io.*
disp("1. Matlab.net tools loaded ...")
api_key = string(fileread("KEY.txt"));
disp(["2. API key loaded: "+ api_key]);
disp("Please Provide your API KEY by editing 'KEY.txt'.");
HeaderField('Content-Type', 'application/json')
HeaderField('Authorization', ['Bearer ' + api_key])
disp("3. Header generated: ");
disp(app.header(2).Value);
Other function that will use HTTP (I have to import them again)
function ModelDropDownValueChanged(app, event)
import matlab.net.http.io.*
selected_model = app.ModelDropDown.Value;
if selected_model == "GPT3.5Turbo"
app.model = 'gpt-3.5-turbo';
app.endpoint = "https://api.openai.com/v1/chat/completions";
elseif selected_model == "GPT3.5"
app.model = 'gpt-3.5-0301';
app.model = 'davinci-v3';
disp("Selected Model is: " + app.model);