Skip to content

Commit a0a1e77

Browse files
committed
Update
1 parent bb05a2e commit a0a1e77

2 files changed

Lines changed: 4 additions & 104 deletions

File tree

mod.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
"huggingface-api-key": { "type": "string", "default": "" },
4444
"use-platinum": { "type": "bool", "default": false },
4545
"ollama-model": { "type": "string", "default": "entity12208/editorai:deepseek" },
46-
"local-url": { "type": "string", "default": "http://localhost:11435" },
47-
"local-model": { "type": "string", "default": "editorai" },
4846
"ollama-timeout": { "type": "int", "default": 600, "min": 60, "max": 1800 },
4947
"enable-rate-limiting": { "type": "bool", "default": true },
5048
"rate-limit-seconds": { "type": "int", "default": 3, "min": 1, "max": 60 },

src/main.cpp

Lines changed: 4 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ static std::string getProviderModel(const std::string& provider) {
275275
if (provider == "ministral") return Mod::get()->getSettingValue<std::string>("ministral-model");
276276
if (provider == "huggingface") return Mod::get()->getSettingValue<std::string>("huggingface-model");
277277
if (provider == "ollama") return Mod::get()->getSettingValue<std::string>("ollama-model");
278-
if (provider == "local") return Mod::get()->getSettingValue<std::string>("local-model");
279278
return "unknown";
280279
}
281280

@@ -286,10 +285,6 @@ static std::string getOllamaUrl() {
286285
: "http://localhost:11434";
287286
}
288287

289-
static std::string getLocalUrl() {
290-
return Mod::get()->getSettingValue<std::string>("local-url");
291-
}
292-
293288
// ─── Deferred object struct ───────────────────────────────────────────────────
294289

295290
struct DeferredObject {
@@ -804,9 +799,7 @@ class AISettingsPopup : public Popup {
804799
std::vector<IntInputMeta> m_intInputs;
805800
std::vector<CCMenuItemSpriteExtra*> m_tabBtns;
806801
async::TaskHolder<web::WebResponse> m_ollamaListener;
807-
async::TaskHolder<web::WebResponse> m_localListener;
808802
std::vector<std::string> m_ollamaModels; // auto-detected
809-
std::vector<std::string> m_localModels; // auto-detected from local server
810803

811804
float m_rowY = 0;
812805
float m_labelX = 0;
@@ -1030,7 +1023,7 @@ class AISettingsPopup : public Popup {
10301023

10311024
void buildGeneralTab() {
10321025
addCycler("Provider:", "ai-provider",
1033-
{"gemini", "claude", "openai", "ministral", "huggingface", "ollama", "local"});
1026+
{"gemini", "claude", "openai", "ministral", "huggingface", "ollama"});
10341027
addCycler("Difficulty:", "difficulty",
10351028
{"easy", "medium", "hard", "extreme"});
10361029
addCycler("Style:", "style",
@@ -1081,30 +1074,10 @@ class AISettingsPopup : public Popup {
10811074
}
10821075

10831076
addIntRow("Timeout (s):", "ollama-timeout", 60, 1800, 600);
1084-
} else if (provider == "local") {
1085-
addTextRow("Server URL:", "local-url", "http://localhost:11435", 200);
1086-
1087-
// Auto-detect models from local server
1088-
if (m_localModels.empty()) {
1089-
addInfoRow("Model:", "Detecting...", {200, 200, 100});
1090-
fetchLocalModels();
1091-
} else if (m_localModels.size() == 1 && m_localModels[0].rfind("(", 0) == 0) {
1092-
addInfoRow("Model:", m_localModels[0], {255, 100, 100});
1093-
} else {
1094-
addCycler("Model:", "local-model", m_localModels);
1095-
}
1096-
1097-
auto hint = CCLabelBMFont::create(
1098-
"Your own trained model. Run: python training/server/serve.py",
1099-
"bigFont.fnt");
1100-
hint->setScale(0.18f);
1101-
hint->setColor({150, 150, 150});
1102-
hint->setPosition({this->m_size.width / 2, m_rowY - 8});
1103-
m_contentLayer->addChild(hint);
11041077
}
11051078

11061079
// Hint about key security
1107-
if (provider != "ollama" && provider != "local") {
1080+
if (provider != "ollama") {
11081081
auto hint = CCLabelBMFont::create("Keys stored locally in Geode save data.", "bigFont.fnt");
11091082
hint->setScale(0.2f);
11101083
hint->setColor({150, 150, 150});
@@ -1189,55 +1162,7 @@ class AISettingsPopup : public Popup {
11891162
);
11901163
}
11911164

1192-
void fetchLocalModels() {
1193-
// Save text inputs first so local-url is committed
1194-
saveTextInputs();
1195-
std::string localUrl = Mod::get()->getSettingValue<std::string>("local-url");
1196-
log::info("Fetching models from Local AI server: {}/api/tags", localUrl);
1197-
1198-
auto request = web::WebRequest();
1199-
request.timeout(std::chrono::seconds(5));
1200-
1201-
m_localListener.spawn(
1202-
request.get(localUrl + "/api/tags"),
1203-
[this](web::WebResponse response) {
1204-
if (!response.ok()) {
1205-
int code = response.code();
1206-
log::warn("Local AI server not reachable: HTTP {}", code);
1207-
m_localModels = code == 0
1208-
? std::vector<std::string>{"(server not running)"}
1209-
: std::vector<std::string>{fmt::format("(error: HTTP {})", code)};
1210-
buildTab(SettingsTab::Provider);
1211-
return;
1212-
}
1213-
1214-
auto jsonRes = response.json();
1215-
if (!jsonRes) {
1216-
m_localModels = {"(invalid response)"};
1217-
buildTab(SettingsTab::Provider);
1218-
return;
1219-
}
1220-
1221-
auto json = jsonRes.unwrap();
1222-
m_localModels.clear();
1223-
1224-
if (json.contains("models") && json["models"].isArray()) {
1225-
for (size_t i = 0; i < json["models"].size(); ++i) {
1226-
auto nameResult = json["models"][i]["name"].asString();
1227-
if (nameResult)
1228-
m_localModels.push_back(nameResult.unwrap());
1229-
}
1230-
}
1231-
1232-
if (m_localModels.empty()) {
1233-
m_localModels = {"(no models loaded)"};
1234-
}
12351165

1236-
log::info("Detected {} models from Local AI server", m_localModels.size());
1237-
buildTab(SettingsTab::Provider);
1238-
}
1239-
);
1240-
}
12411166

12421167
// ── Cycler callbacks ────────────────────────────────────────────────
12431168

@@ -1273,7 +1198,6 @@ class AISettingsPopup : public Popup {
12731198
// If provider changed, rebuild Provider tab data
12741199
if (info.settingId == "ai-provider" && m_currentTab == SettingsTab::Provider) {
12751200
m_ollamaModels.clear();
1276-
m_localModels.clear();
12771201
buildTab(SettingsTab::Provider);
12781202
}
12791203

@@ -1525,8 +1449,6 @@ class AIGeneratorPopup : public Popup {
15251449
if (provider == "ollama") {
15261450
bool usePlatinum = Mod::get()->getSettingValue<bool>("use-platinum");
15271451
keyStatus = usePlatinum ? "<cg>Platinum cloud</c>" : "<cg>Local — no key needed</c>";
1528-
} else if (provider == "local") {
1529-
keyStatus = "<cg>Local AI — no key needed</c>";
15301452
} else {
15311453
keyStatus = apiKey.empty()
15321454
? "<cr>Not set — go to mod settings</c>"
@@ -2650,24 +2572,6 @@ class AIGeneratorPopup : public Popup {
26502572
requestBody["options"] = options;
26512573

26522574
url = ollamaUrl + "/api/generate";
2653-
2654-
// ── Local AI (EditorAI trained model) ─────────────────────────────────
2655-
// Uses the same NDJSON streaming API as Ollama, served by training/server/serve.py
2656-
} else if (provider == "local") {
2657-
std::string localUrl = getLocalUrl();
2658-
log::info("Using Local AI at: {}", localUrl + "/api/generate");
2659-
2660-
auto options = matjson::Value::object();
2661-
options["temperature"] = 0.7;
2662-
2663-
requestBody = matjson::Value::object();
2664-
requestBody["model"] = model;
2665-
requestBody["prompt"] = systemPrompt + "\n\n" + fullPrompt;
2666-
requestBody["stream"] = true;
2667-
requestBody["format"] = "json";
2668-
requestBody["options"] = options;
2669-
2670-
url = localUrl + "/api/generate";
26712575
}
26722576

26732577
std::string jsonBody = requestBody.dump();
@@ -2688,8 +2592,6 @@ class AIGeneratorPopup : public Popup {
26882592
// Ollama can be very slow on large models with partial GPU offload.
26892593
int timeoutSec = (int)Mod::get()->getSettingValue<int64_t>("ollama-timeout");
26902594
request.timeout(std::chrono::seconds(timeoutSec));
2691-
} else if (provider == "local") {
2692-
request.timeout(std::chrono::seconds(300));
26932595
}
26942596

26952597
request.bodyString(jsonBody);
@@ -2747,7 +2649,7 @@ class AIGeneratorPopup : public Popup {
27472649
std::string provider = Mod::get()->getSettingValue<std::string>("ai-provider");
27482650
std::string apiKey = getProviderApiKey(provider);
27492651

2750-
if (apiKey.empty() && provider != "ollama" && provider != "local") {
2652+
if (apiKey.empty() && provider != "ollama") {
27512653
FLAlertLayer::create("API Key Required",
27522654
gd::string(fmt::format(
27532655
"Please open mod settings and enter your API key under the {} section.",
@@ -2812,7 +2714,7 @@ class AIGeneratorPopup : public Popup {
28122714
// and always fails on streaming output. We must parse line by line,
28132715
// accumulate all "response" fields, and verify "done":true on the
28142716
// final line.
2815-
if (provider == "ollama" || provider == "local") {
2717+
if (provider == "ollama") {
28162718
auto rawResult = response.string();
28172719
if (!rawResult) {
28182720
onError("Invalid Response", "The API returned invalid data.");

0 commit comments

Comments
 (0)