To add the new models to your code without changing any other code, you simply need to update the models list in your code by including the new models. Here's the updated section of your code with the new models added:
Http.get(apiUrl, nil, function(code, content)
if code == 200 then
local json = JSONObject(content)
local status, message, model
if mode == "AI Search" then
status = true
message = json.optString("data", "")
model = "AI Search"
elseif mode == "Bing" or mode == "Blackbox" or mode == "Llama" or mode == "Qwen" or mode == "Gemini" then
status = json.optBoolean("status", false)
message = json.optString("message", "")
model = json.optString("model", "")
elseif mode == "ChatGPT API 1" or mode == "ChatGPT API 2" or mode == "AI Girlfriend" or mode:find("Advanced ChatGPT") or mode == "Jarvis" or mode == "Zenith AI" then
status = true
message = json.optString("answer", "")
model = mode
elseif mode == "Advanced Image Generator" then
status = true
local images = json.optJSONArray("images")
message = images and images.getString(0) or ""
model = "Advanced Image Generator"
elseif mode == "Generate Images with Prompts" then
status = true
local images = json.optJSONArray("images")
message = "Generated " .. images.length() .. " images:\n\n"
for i = 0, images.length() - 1 do
message = message .. (i + 1) .. ". " .. images.getString(i) .. "\n"
end
model = "Generate Images with Prompts"
else
status = json.optBoolean("status", false)
message = json.optString("gpt", "")
model = json.optString("model", "")
end
if status and message ~= "" then
callback(message, model, nil)
else
callback(nil, nil, "Invalid API response")
end
else
callback(nil, nil, "Error generating response. Status code: " .. code)
end
-- Function to update result text
function updateResultText(result)
resultText.text = result
end
-- Set up generate response button
generateResponseButton.onClick = function()
local mode = modelSpinner.selectedItem
local question = questionInput.text
if question and #question > 0 then
updateResultText("Generating AI response...")
generateAIResponse(mode, question, function(response, model, error)
if error then
updateResultText("Error: " .. error)
else
updateResultText("AI Response (" .. model .. "):\n\n" .. response)
end
end)
-- Clear the text field after sending
questionInput.text = ""
else
updateResultText("Please enter a question for AI response generation")
end
end
-- Set up exit button
exitButton.onClick = function()
dlg.dismiss()
end
-- Show dialog
dlg.show()
By adding the new models to the models array, they will now appear in the spinner for selection within your app. You don't need to modify any other part of your code—the rest of your code will handle the selected model as it already does.
Note: Ensure that any backend or API endpoints that handle these new models are correctly set up to respond to requests using these model names. If necessary, verify that the API URLs and parameters in your generateAIResponse function support these new models.