Optimize startup, HTTP/SSE streaming, and fix macOS libedit bindings
This commit is contained in:
+6
-4
@@ -87,7 +87,7 @@ static void parse_cfg_file(std::string_view path, Cfg &c, std::set<std::string>
|
||||
else if (k == "max_al_iterations") c.max_al_iterations = to_int_val(v, c.max_al_iterations);
|
||||
else if (k == "stream") c.stream = (v == "true" || v == "1" || v == "yes");
|
||||
else if (k == "color") c.color = std::string(v);
|
||||
else if (k == "context_window") c.context_window = to_int_val(v, c.context_window);
|
||||
else if (k == "context_window") { c.context_window = to_int_val(v, c.context_window); c.context_window_set = true; }
|
||||
else if (k == "max_tool_res") c.max_tool_res = to_int_val(v, c.max_tool_res);
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,7 @@ static void apply_env_cfg(Cfg &c, const std::set<std::string> &file_keys) {
|
||||
if ((e = ev("timeout", "BANTAM_TIMEOUT"))) { c.timeout = to_int_val(e, c.timeout); cfg_raw_set(c, "timeout", e); }
|
||||
if ((e = ev("shell_timeout", "BANTAM_SHELL_TIMEOUT"))) { c.shell_timeout = to_int_val(e, c.shell_timeout); cfg_raw_set(c, "shell_timeout", e); }
|
||||
if ((e = ev("max_al_iterations", "BANTAM_MAX_AL_ITERATIONS"))) { c.max_al_iterations = to_int_val(e, c.max_al_iterations); cfg_raw_set(c, "max_al_iterations", e); }
|
||||
if ((e = ev("context_window", "BANTAM_CONTEXT_WINDOW"))) { c.context_window = to_int_val(e, c.context_window); cfg_raw_set(c, "context_window", e); }
|
||||
if ((e = ev("context_window", "BANTAM_CONTEXT_WINDOW"))) { c.context_window = to_int_val(e, c.context_window); c.context_window_set = true; cfg_raw_set(c, "context_window", e); }
|
||||
if ((e = ev("max_tool_res", "BANTAM_MAX_TOOL_RES"))) { c.max_tool_res = to_int_val(e, c.max_tool_res); cfg_raw_set(c, "max_tool_res", e); }
|
||||
if ((e = ev("reasoning_effort", "BANTAM_REASONING_EFFORT"))) cfg_raw_set(c, "reasoning_effort", e);
|
||||
if ((e = ev("bantam_tools_dir", "BANTAM_TOOLS_DIR"))) cfg_raw_set(c, "bantam_tools_dir", e);
|
||||
@@ -211,6 +211,7 @@ static int query_models_context_window(Cfg &cfg) {
|
||||
}
|
||||
|
||||
int fetch_context_window(Cfg &cfg) {
|
||||
if (cfg.context_window_set && cfg.context_window > 0) return cfg.context_window;
|
||||
static std::map<std::string, int> cache;
|
||||
std::string key = cfg.endpoint + std::string(1, '\0') + cfg.model;
|
||||
auto it = cache.find(key);
|
||||
@@ -218,8 +219,9 @@ int fetch_context_window(Cfg &cfg) {
|
||||
int cw = query_models_context_window(cfg);
|
||||
if (cw > 0) { cache[key] = cw; return cw; }
|
||||
const std::string *v = cfg_raw_get(cfg, "context_window");
|
||||
if (v && !v->empty()) return to_int_val(*v, 262144);
|
||||
return 262144;
|
||||
int fallback = (v && !v->empty()) ? to_int_val(*v, 262144) : 262144;
|
||||
cache[key] = fallback;
|
||||
return fallback;
|
||||
}
|
||||
|
||||
std::string list_models(Cfg &cfg, int *errout) {
|
||||
|
||||
Reference in New Issue
Block a user