-
Notifications
You must be signed in to change notification settings - Fork 370
refactor(backends): self-describing WrappedServer backends (#2287) #2320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 36 commits
118f54a
2ef9379
33b437b
84616c4
2d1fd36
9b8383c
566ea83
cfb6e3d
5a1d534
7933852
2cc963e
2feae84
4354260
2a9b38e
623334c
ae8ca93
add34ed
94ebbab
1ced08c
e89b47c
55fa6f1
c3aff59
de6d3b1
070fcbc
554ab6c
b4547cd
71c1bb1
a54cacd
7d82220
6492260
f7ec14c
6cc9552
d0368da
e14fc2a
5daebd5
a288c48
43ec4f2
8f6f36e
2ac10fd
283297a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -607,15 +607,6 @@ set(SOURCES_CORE | |
| src/cpp/server/utils/wmi_helper.cpp | ||
| src/cpp/server/utils/network_beacon.cpp | ||
| src/cpp/server/utils/tcp_jsonl_client.cpp | ||
| src/cpp/server/backends/cloud_server.cpp | ||
| src/cpp/server/backends/llamacpp_server.cpp | ||
| src/cpp/server/backends/fastflowlm_server.cpp | ||
| src/cpp/server/backends/ryzenaiserver.cpp | ||
| src/cpp/server/backends/whisper_server.cpp | ||
| src/cpp/server/backends/moonshine_server.cpp | ||
| src/cpp/server/backends/kokoro_server.cpp | ||
| src/cpp/server/backends/sd_server.cpp | ||
| src/cpp/server/backends/vllm_server.cpp | ||
| src/cpp/server/backends/backend_utils.cpp | ||
| src/cpp/server/backend_manager.cpp | ||
| src/cpp/server/ollama_api.cpp | ||
|
|
@@ -647,6 +638,83 @@ elseif(UNIX) | |
| list(APPEND SOURCES_CORE src/cpp/server/utils/platform/process_unix.cpp) | ||
| endif() | ||
|
|
||
| # ============================================================ | ||
| # Self-describing backends registry | ||
| # ============================================================ | ||
| # The authoritative backend list. Each entry is "<recipe>|<stem>": | ||
| # recipe - the recipe string used in server_models.json (may contain dashes) | ||
| # stem - identifier-safe name and folder. Each backend lives in its own | ||
| # folder, shipping (in namespace lemon::backends::<stem>): | ||
| # include/lemon/backends/<stem>/<stem>.h inline const descriptor (CLI-safe data) | ||
| # include/lemon/backends/<stem>/<stem>_server.h WrappedServer subclass + create() decl | ||
| # server/backends/<stem>/<stem>_server.cpp implementation + create() def | ||
| # | ||
| # Adding a backend is one line here plus that folder. The foreach below compiles | ||
| # the server source and regenerates the registry headers, which bind each | ||
| # descriptor to its create(). Because this list is a tracked input, editing it | ||
| # forces regeneration on the next build (a file(GLOB) would silently miss a | ||
| # newly added backend). The descriptor is a header-only inline const, so it links | ||
| # into both the lemonade CLI and lemond; only lemond links the server sources. | ||
| set(LEMON_BACKENDS | ||
| # "<recipe>|<stem>" | ||
| "llamacpp|llamacpp" | ||
| "whispercpp|whispercpp" | ||
| "moonshine|moonshine" | ||
| "kokoro|kokoro" | ||
| "sd-cpp|sdcpp" | ||
| "flm|fastflowlm" | ||
| "ryzenai-llm|ryzenai" | ||
| "vllm|vllm" | ||
| "cloud|cloud" | ||
| ) | ||
|
|
||
| set(LEMON_DESCRIPTOR_INCLUDES "") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are fine here. |
||
| set(LEMON_DESCRIPTOR_ENTRIES "") | ||
| set(LEMON_FACTORY_INCLUDES "") | ||
| set(LEMON_FACTORY_ENTRIES "") | ||
| # The data registry (descriptors, header-only) links into both binaries; the | ||
| # factory registry + per-backend server sources are server-only. | ||
| # Absolute paths so the CLI subdirectory can reuse LEMON_BACKEND_DESCRIPTOR_SOURCES. | ||
| set(LEMON_BACKEND_DESCRIPTOR_SOURCES | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/server/backends/backend_descriptor_registry.cpp) | ||
| set(LEMON_BACKEND_FACTORY_SOURCES | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/server/backends/backend_registry.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/server/backends/backend_ops.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/server/backends/hf_cache_util.cpp) | ||
| foreach(_backend_entry ${LEMON_BACKENDS}) | ||
| string(REPLACE "|" ";" _backend_parts "${_backend_entry}") | ||
| list(GET _backend_parts 1 _backend_stem) | ||
| # The descriptor is header-only (no source). Compile every .cpp in the | ||
| # backend's folder (server class + any backend-private helpers like GGUF | ||
| # parsing) — CONFIGURE_DEPENDS re-globs when a file is added/removed so a new | ||
| # helper in a folder needs no CMake edit. (The backend LIST is still explicit | ||
| # above so a whole new backend is never silently missed.) | ||
| file(GLOB _backend_srcs CONFIGURE_DEPENDS | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/server/backends/${_backend_stem}/*.cpp) | ||
| list(APPEND LEMON_BACKEND_FACTORY_SOURCES ${_backend_srcs}) | ||
| string(APPEND LEMON_DESCRIPTOR_INCLUDES | ||
| "#include \"lemon/backends/${_backend_stem}/${_backend_stem}.h\"\n") | ||
| string(APPEND LEMON_DESCRIPTOR_ENTRIES | ||
| " &lemon::backends::${_backend_stem}::descriptor,\n") | ||
| string(APPEND LEMON_FACTORY_INCLUDES | ||
| "#include \"lemon/backends/${_backend_stem}/${_backend_stem}_server.h\"\n") | ||
| string(APPEND LEMON_FACTORY_ENTRIES | ||
| " { &lemon::backends::${_backend_stem}::descriptor, &lemon::backends::${_backend_stem}::create, lemon::backends::${_backend_stem}::spec(), lemon::backends::${_backend_stem}::ops() },\n") | ||
| endforeach() | ||
|
|
||
| configure_file( | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/server/backends/backend_descriptors_generated.h.in | ||
| ${CMAKE_CURRENT_BINARY_DIR}/include/backend_descriptors_generated.h | ||
| @ONLY) | ||
| configure_file( | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/server/backends/backend_factories_generated.h.in | ||
| ${CMAKE_CURRENT_BINARY_DIR}/include/backend_factories_generated.h | ||
| @ONLY) | ||
|
|
||
| # lemond gets both descriptor data and factories; the CLI gets only the data | ||
| # (see src/cpp/cli/CMakeLists.txt, which reuses LEMON_BACKEND_DESCRIPTOR_SOURCES). | ||
| list(APPEND SOURCES_CORE ${LEMON_BACKEND_DESCRIPTOR_SOURCES} ${LEMON_BACKEND_FACTORY_SOURCES}) | ||
|
|
||
| # ============================================================ | ||
| # Server core OBJECT library (shared by lemond and Lemonade.exe) | ||
| # ============================================================ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,25 +2,25 @@ const GITHUB_REPO = 'lemonade-sdk/lemonade'; | |
| const TAGS_URL = `https://api.github.com/repos/${GITHUB_REPO}/tags?per_page=100`; | ||
| const RAW_BASE = 'https://raw.githubusercontent.com/lemonade-sdk/lemonade'; | ||
|
|
||
| /* BEGIN GENERATED: models-js-recipes */ | ||
| const RECIPE_PRIORITY = [ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see moonshine in here. |
||
| 'llamacpp', | ||
| 'ryzenai-llm', | ||
| 'flm', | ||
| 'whispercpp', | ||
| 'sd-cpp', | ||
| 'oga-hybrid', | ||
| 'oga-npu', | ||
| 'oga-cpu', | ||
| 'kokoro' | ||
| ]; | ||
|
|
||
| const RECIPE_DISPLAY_NAMES = { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moonshine seems to be missing here too |
||
| llamacpp: 'llama.cpp GPU', | ||
| 'ryzenai-llm': 'Ryzen AI SW NPU', | ||
| flm: 'FastFlowLM NPU', | ||
| whispercpp: 'whisper.cpp', | ||
| 'sd-cpp': 'stable-diffusion.cpp' | ||
| 'sd-cpp': 'stable-diffusion.cpp', | ||
| flm: 'FastFlowLM NPU', | ||
| 'ryzenai-llm': 'Ryzen AI SW NPU', | ||
| vllm: 'vLLM ROCm (experimental)' | ||
| }; | ||
| /* END GENERATED: models-js-recipes */ | ||
|
|
||
| const state = { | ||
| tag: null, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these should be as close to the top of the file as possible honestly.