Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions main/cli/serial_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ static struct {
struct arg_end *end;
} api_key_args;

/* --- set_api_base command --- */
static struct {
struct arg_str *base;
struct arg_end *end;
} api_base_args;

static int cmd_set_api_key(int argc, char **argv)
{
int nerrors = arg_parse(argc, argv, (void **)&api_key_args);
Expand All @@ -135,6 +141,18 @@ static int cmd_set_api_key(int argc, char **argv)
return 0;
}

static int cmd_set_api_base(int argc, char **argv)
{
int nerrors = arg_parse(argc, argv, (void **)&api_base_args);
if (nerrors != 0) {
arg_print_errors(stderr, api_base_args.end, argv[0]);
return 1;
}
llm_set_api_base(api_base_args.base->sval[0]);
printf("API base set.\n");
return 0;
}
Comment thread
IRONICBo marked this conversation as resolved.

/* --- set_model command --- */
static struct {
struct arg_str *model;
Expand Down Expand Up @@ -535,6 +553,7 @@ static int cmd_config_show(int argc, char **argv)
print_config("WiFi Pass", MIMI_NVS_WIFI, MIMI_NVS_KEY_PASS, MIMI_SECRET_WIFI_PASS, true);
print_config("TG Token", MIMI_NVS_TG, MIMI_NVS_KEY_TG_TOKEN, MIMI_SECRET_TG_TOKEN, true);
print_config("API Key", MIMI_NVS_LLM, MIMI_NVS_KEY_API_KEY, MIMI_SECRET_API_KEY, true);
print_config("API Base", MIMI_NVS_LLM, MIMI_NVS_KEY_API_BASE, MIMI_SECRET_API_BASE, false);
print_config("Model", MIMI_NVS_LLM, MIMI_NVS_KEY_MODEL, MIMI_SECRET_MODEL, false);
print_config("Provider", MIMI_NVS_LLM, MIMI_NVS_KEY_PROVIDER, MIMI_SECRET_MODEL_PROVIDER, false);
print_config("Proxy Host", MIMI_NVS_PROXY, MIMI_NVS_KEY_PROXY_HOST, MIMI_SECRET_PROXY_HOST, false);
Expand Down Expand Up @@ -849,6 +868,17 @@ esp_err_t serial_cli_init(void)
};
esp_console_cmd_register(&api_key_cmd);

/* set_api_base */
api_base_args.base = arg_str1(NULL, NULL, "<base>", "LLM API base (http(s)://host[:port][/path])");
api_base_args.end = arg_end(1);
esp_console_cmd_t api_base_cmd = {
.command = "set_api_base",
.help = "Set LLM API base (e.g. https://api.anthropic.com/v1)",
.func = &cmd_set_api_base,
.argtable = &api_base_args,
};
esp_console_cmd_register(&api_base_cmd);

/* set_model */
model_args.model = arg_str1(NULL, NULL, "<model>", "Model identifier");
model_args.end = arg_end(1);
Expand Down
Loading