Loading editor/src/webedit_api.cpp +5 −6 Changes for editor/src/webedit_api.cpp: 5 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -3336,8 +3336,6 @@ void webedit::Api::handleAiSettings(libhttppp::HttpRequest &curreq) { namespace { constexpr int kMaxAiToolRounds = 6; json_object *aiToolFunction(const char *name, const char *description, json_object *schema) { json_object *fn = json_object_new_object(); json_object_object_add(fn, "name", json_object_new_string(name)); Loading Loading @@ -3647,8 +3645,8 @@ json_object *webedit::Api::callAiTool(const std::string &sessionid, const std::s void webedit::Api::handleAiPrompt(libhttppp::HttpRequest &curreq, const std::string &sessionid) { // Admission control: this handler can block its worker thread for // minutes if the AI backend is slow/stuck (see kMaxAiToolRounds's // per-round connect/read timeouts below). The server's worker pool is // minutes if the AI backend is slow/stuck (see the AI_MAX_TOOL_ROUNDS // setting's per-round connect/read timeouts below). The server's worker pool is // small and fixed-size (roughly one per CPU core) and shared by every // route, so letting unbounded concurrent AI requests pile up can starve // completely unrelated endpoints. Reject early instead of queuing up Loading Loading @@ -3700,6 +3698,7 @@ void webedit::Api::handleAiPrompt(libhttppp::HttpRequest &curreq, std::string aiUrl = _db.getOption("AI_URL", "http://localhost:11434"); std::string aiModel = _db.getOption("AI_MODEL", ""); int maxTokens = std::stoi(_db.getOption("AI_MAX_TOKENS", "16384")); int maxToolRounds = std::stoi(_db.getOption("AI_MAX_TOOL_ROUNDS", "20")); if (aiUrl.empty() || aiModel.empty()) { sendJsonError(curreq, 400, "AI not configured"); Loading Loading @@ -3759,7 +3758,7 @@ void webedit::Api::handleAiPrompt(libhttppp::HttpRequest &curreq, bool haveFinal = false; try { for (int round = 0; round < kMaxAiToolRounds && !haveFinal; ++round) { for (int round = 0; round < maxToolRounds && !haveFinal; ++round) { json_object *aiReq = json_object_new_object(); json_object_object_add(aiReq, "model", json_object_new_string(aiModel.c_str())); json_object_object_add(aiReq, "max_tokens", json_object_new_int(maxTokens)); Loading Loading @@ -3939,7 +3938,7 @@ void webedit::Api::handleAiPrompt(libhttppp::HttpRequest &curreq, bool haveFinal = false; try { for (int round = 0; round < kMaxAiToolRounds && !haveFinal && !clientGone; ++round) { for (int round = 0; round < maxToolRounds && !haveFinal && !clientGone; ++round) { json_object *aiReq = json_object_new_object(); json_object_object_add(aiReq, "model", json_object_new_string(aiModel.c_str())); json_object_object_add(aiReq, "max_tokens", json_object_new_int(maxTokens)); Loading Loading
editor/src/webedit_api.cpp +5 −6 Changes for editor/src/webedit_api.cpp: 5 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -3336,8 +3336,6 @@ void webedit::Api::handleAiSettings(libhttppp::HttpRequest &curreq) { namespace { constexpr int kMaxAiToolRounds = 6; json_object *aiToolFunction(const char *name, const char *description, json_object *schema) { json_object *fn = json_object_new_object(); json_object_object_add(fn, "name", json_object_new_string(name)); Loading Loading @@ -3647,8 +3645,8 @@ json_object *webedit::Api::callAiTool(const std::string &sessionid, const std::s void webedit::Api::handleAiPrompt(libhttppp::HttpRequest &curreq, const std::string &sessionid) { // Admission control: this handler can block its worker thread for // minutes if the AI backend is slow/stuck (see kMaxAiToolRounds's // per-round connect/read timeouts below). The server's worker pool is // minutes if the AI backend is slow/stuck (see the AI_MAX_TOOL_ROUNDS // setting's per-round connect/read timeouts below). The server's worker pool is // small and fixed-size (roughly one per CPU core) and shared by every // route, so letting unbounded concurrent AI requests pile up can starve // completely unrelated endpoints. Reject early instead of queuing up Loading Loading @@ -3700,6 +3698,7 @@ void webedit::Api::handleAiPrompt(libhttppp::HttpRequest &curreq, std::string aiUrl = _db.getOption("AI_URL", "http://localhost:11434"); std::string aiModel = _db.getOption("AI_MODEL", ""); int maxTokens = std::stoi(_db.getOption("AI_MAX_TOKENS", "16384")); int maxToolRounds = std::stoi(_db.getOption("AI_MAX_TOOL_ROUNDS", "20")); if (aiUrl.empty() || aiModel.empty()) { sendJsonError(curreq, 400, "AI not configured"); Loading Loading @@ -3759,7 +3758,7 @@ void webedit::Api::handleAiPrompt(libhttppp::HttpRequest &curreq, bool haveFinal = false; try { for (int round = 0; round < kMaxAiToolRounds && !haveFinal; ++round) { for (int round = 0; round < maxToolRounds && !haveFinal; ++round) { json_object *aiReq = json_object_new_object(); json_object_object_add(aiReq, "model", json_object_new_string(aiModel.c_str())); json_object_object_add(aiReq, "max_tokens", json_object_new_int(maxTokens)); Loading Loading @@ -3939,7 +3938,7 @@ void webedit::Api::handleAiPrompt(libhttppp::HttpRequest &curreq, bool haveFinal = false; try { for (int round = 0; round < kMaxAiToolRounds && !haveFinal && !clientGone; ++round) { for (int round = 0; round < maxToolRounds && !haveFinal && !clientGone; ++round) { json_object *aiReq = json_object_new_object(); json_object_object_add(aiReq, "model", json_object_new_string(aiModel.c_str())); json_object_object_add(aiReq, "max_tokens", json_object_new_int(maxTokens)); Loading