nits fixes

This commit is contained in:
Xuan Son Nguyen
2026-07-07 22:25:21 +02:00
parent 50ed8076fb
commit 1729662ea3
3 changed files with 15 additions and 7 deletions
+3 -2
View File
@@ -10,6 +10,7 @@
#include <nlohmann/json.hpp>
#include <algorithm>
#include <cctype>
#include <filesystem>
#include <fstream>
#include <map>
@@ -81,7 +82,7 @@ static std::string format_error_message(const std::string & err) {
static std::string media_type_from_ext(const std::string & fname) {
std::string ext = std::filesystem::path(fname).extension().string();
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
std::transform(ext.begin(), ext.end(), ext.begin(), [](unsigned char c) { return std::tolower(c); });
if (ext == ".wav" || ext == ".mp3") {
return "audio";
}
@@ -281,7 +282,7 @@ bool cli_context::stage_media_file(const std::string & fname, const std::string
if (type == "audio") {
std::string ext = std::filesystem::path(fname).extension().string();
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
std::transform(ext.begin(), ext.end(), ext.begin(), [](unsigned char c) { return std::tolower(c); });
impl->pending_media.push_back({
{"type", "input_audio"},
{"input_audio", {
+10 -4
View File
@@ -19,8 +19,13 @@ struct cli_server {
}
void stop() {
if (alive() && !is_stopping.exchange(true)) {
if (is_stopping.exchange(true)) {
return;
}
if (alive()) {
llama_server_terminate();
}
if (th.joinable()) {
th.join();
}
}
@@ -35,9 +40,10 @@ struct cli_server {
is_alive.store(true, std::memory_order_release);
th = std::thread([&]() {
common_params server_params = params; // copy
server_params.port = port;
common_params server_params = params; // copy
server_params.port = port;
th = std::thread([this, server_params]() mutable {
// argc / argv are only used in router mode, we can skip them for now
int res = llama_server(server_params, 0, nullptr);
if (res != 0) {
+2 -1
View File
@@ -5,6 +5,7 @@
#include <array>
#include <algorithm>
#include <cctype>
#include <filesystem>
#include <string_view>
@@ -61,7 +62,7 @@ static std::vector<std::pair<std::string, size_t>> auto_completion_callback(std:
}
if (string_starts_with(expanded_prefix, '/')) {
#else
if (std::isalpha(expanded_prefix[0]) && expanded_prefix.find(':') == 1) {
if (std::isalpha(static_cast<unsigned char>(expanded_prefix[0])) && expanded_prefix.find(':') == 1) {
#endif
cur_dir = std::filesystem::path(expanded_prefix).parent_path();
cur_dir_str.clear();