diff options
| author | Michael Peter Christen <mc@yacy.net> | 2026-03-28 16:17:52 +0100 |
|---|---|---|
| committer | Michael Peter Christen <mc@yacy.net> | 2026-03-28 16:17:52 +0100 |
| commit | af97d3a682cb7c4bbb4f37fb42246b4ef6fc2ef2 (patch) | |
| tree | 3756748eb034cdce156ca7dbf0cb9f0601beadac /source | |
| parent | 31d6de21f4f64ef1f3075f3a4046758e13b2be35 (diff) | |
more models
Diffstat (limited to 'source')
| -rw-r--r-- | source/net/yacy/htroot/LLMSelection_p.java | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/source/net/yacy/htroot/LLMSelection_p.java b/source/net/yacy/htroot/LLMSelection_p.java index 68767db04..de2807d4a 100644 --- a/source/net/yacy/htroot/LLMSelection_p.java +++ b/source/net/yacy/htroot/LLMSelection_p.java @@ -35,6 +35,27 @@ import net.yacy.server.serverSwitch; public class LLMSelection_p { + private static JSONObject normalizeProductionModelRow(final JSONObject row) throws JSONException { + final JSONObject normalized = new JSONObject(true); + normalized.put("service", row.optString("service", "OLLAMA")); + normalized.put("model", row.optString("model", "")); + normalized.put("hoststub", row.optString("hoststub", "")); + normalized.put("api_key", row.optString("api_key", "")); + normalized.put("max_tokens", row.optString("max_tokens", "4096")); + + normalized.put("search", false); + normalized.put("chat", row.optBoolean("chat", false)); + normalized.put("translation", false); + normalized.put("classification", false); + normalized.put("query", false); + normalized.put("qapairs", false); + normalized.put("tldr", row.optBoolean("tldr", false)); + + normalized.put("tooling", row.optBoolean("tooling", false)); + normalized.put("vision", row.optBoolean("vision", false)); + return normalized; + } + public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) { // return variable that accumulates replacements final Switchboard sb = (Switchboard) env; @@ -53,7 +74,11 @@ public class LLMSelection_p { if (production_models != null) { // simply store the model array try { - sb.setConfig("ai.production_models", production_models.toString(0)); + final JSONArray normalizedModels = new JSONArray(); + for (int i = 0; i < production_models.length(); i++) { + normalizedModels.put(normalizeProductionModelRow(production_models.getJSONObject(i))); + } + sb.setConfig("ai.production_models", normalizedModels.toString(0)); } catch (JSONException e) { //e.printStackTrace(); } @@ -87,7 +112,7 @@ public class LLMSelection_p { try { production_models = new JSONArray(new JSONTokener(pms)); for (int i = 0; i < production_models.length(); i++) { - JSONObject row = production_models.getJSONObject(i); + JSONObject row = normalizeProductionModelRow(production_models.getJSONObject(i)); prop.put("productionmodels_" + i + "_service", row.optString("service", "OLLAMA")); prop.put("productionmodels_" + i + "_model", row.optString("model", "")); prop.put("productionmodels_" + i + "_hoststub", row.optString("hoststub", "")); |
