mirror of
https://github.com/ollama/ollama.git
synced 2026-08-27 04:06:17 +00:00
Bundle llama.cpp UI assets
This commit is contained in:
parent
6efd7a6ece
commit
a2ca874de5
4 changed files with 40 additions and 15 deletions
|
|
@ -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*
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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<asset_entry> assets;
|
||||
BIN
llama/compat/ui/llama-b9626-ui.tar.gz
Normal file
BIN
llama/compat/ui/llama-b9626-ui.tar.gz
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue