diff --git a/llama/compat/README.md b/llama/compat/README.md index 8c356a7dd..cf5f29dcd 100644 --- a/llama/compat/README.md +++ b/llama/compat/README.md @@ -28,6 +28,8 @@ intentionally skipped so a developer can iterate on a local llama.cpp tree. - `compat.cmake`, `apply-patch.cmake` - CMake glue and an idempotent applier (used by `llama/server/CMakeLists.txt`) that applies every `*.patch` under this directory — the hooks patch plus each `models/` architecture patch. +- `ui/llama-*-ui.tar.gz` - prebuilt llama.cpp server UI assets from the pinned + release, extracted into the fetched source before upstream embeds them. - `models/` - the sibling **new-architecture** layer: implementations of architectures llama.cpp doesn't support yet, each added via a small registration patch. (Those files *add* archs; the files above *translate* diff --git a/llama/compat/apply-patch.cmake b/llama/compat/apply-patch.cmake index e7ca91af3..e9b607013 100644 --- a/llama/compat/apply-patch.cmake +++ b/llama/compat/apply-patch.cmake @@ -48,3 +48,41 @@ foreach(PATCH_FILE IN LISTS _patches) message(STATUS "llama/compat: applied patch") endforeach() + +set(_ui_archive "") +set(_llama_cpp_version_file "${PATCH_DIR}/../../LLAMA_CPP_VERSION") +if(EXISTS "${_llama_cpp_version_file}") + file(READ "${_llama_cpp_version_file}" _llama_cpp_tag) + string(STRIP "${_llama_cpp_tag}" _llama_cpp_tag) + set(_ui_archive "${PATCH_DIR}/ui/llama-${_llama_cpp_tag}-ui.tar.gz") +endif() + +if(_ui_archive AND EXISTS "${_ui_archive}") + set(_ui_dist_dir "${_patch_workdir}/tools/ui/dist") + + if(EXISTS "${_ui_dist_dir}/index.html") + message(STATUS "llama/compat: bundled UI assets already present, skipping") + else() + set(_ui_extract_dir "${_patch_workdir}/tools/ui/.ollama-ui-extract") + file(REMOVE_RECURSE "${_ui_extract_dir}") + file(MAKE_DIRECTORY "${_ui_dist_dir}" "${_ui_extract_dir}") + file(ARCHIVE_EXTRACT INPUT "${_ui_archive}" DESTINATION "${_ui_extract_dir}") + + file(GLOB _ui_roots RELATIVE "${_ui_extract_dir}" "${_ui_extract_dir}/*") + list(LENGTH _ui_roots _ui_root_count) + if(NOT _ui_root_count EQUAL 1) + message(FATAL_ERROR + "llama/compat: expected one top-level directory in ${_ui_archive}") + endif() + + list(GET _ui_roots 0 _ui_root) + if(NOT EXISTS "${_ui_extract_dir}/${_ui_root}/index.html") + message(FATAL_ERROR + "llama/compat: ${_ui_archive} does not contain UI assets") + endif() + + file(COPY "${_ui_extract_dir}/${_ui_root}/" DESTINATION "${_ui_dist_dir}") + file(REMOVE_RECURSE "${_ui_extract_dir}") + message(STATUS "llama/compat: extracted bundled UI assets from ${_ui_archive}") + endif() +endif() diff --git a/llama/compat/llama-cpp-ui-empty-assets.patch b/llama/compat/llama-cpp-ui-empty-assets.patch deleted file mode 100644 index 31e90898f..000000000 --- a/llama/compat/llama-cpp-ui-empty-assets.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/tools/ui/embed.cpp b/tools/ui/embed.cpp ---- a/tools/ui/embed.cpp -+++ b/tools/ui/embed.cpp -@@ -147,9 +147,9 @@ int main(int argc, char ** argv) { - - const std::string out_cpp = argv[1]; - const std::string out_h = argv[2]; -- const std::string asset_dir = argv[3]; -+ const std::string asset_dir = argc == 4 ? argv[3] : ""; - -- const bool use_gzip = std::filesystem::exists(asset_dir + "/_gzip"); -+ const bool use_gzip = !asset_dir.empty() && std::filesystem::exists(asset_dir + "/_gzip"); - const std::string in_dir = use_gzip ? (asset_dir + "/_gzip") : asset_dir; - - std::vector assets; diff --git a/llama/compat/ui/llama-b9626-ui.tar.gz b/llama/compat/ui/llama-b9626-ui.tar.gz new file mode 100644 index 000000000..50f845ea8 Binary files /dev/null and b/llama/compat/ui/llama-b9626-ui.tar.gz differ