server: move server-context to its own cpp|h#17595
Merged
Merged
Conversation
ngxson
commented
Nov 29, 2025
Comment on lines
+54
to
+71
| struct server_slots_t { | ||
| ~server_slots_t(); | ||
| std::vector<server_slot*> data; | ||
| size_t size() const { return data.size(); } | ||
| server_slot & operator[](size_t idx) { return *(data[idx]); } | ||
| server_slot & operator[](size_t idx) const { return *(data[idx]); } | ||
| void clear(); | ||
| server_slot & create(); | ||
| struct iterator { | ||
| typename std::vector<server_slot*>::iterator it; | ||
| iterator(typename std::vector<server_slot*>::iterator i) : it(i) {} | ||
| server_slot & operator*() { return **it; } | ||
| iterator & operator++() { ++it; return *this; } | ||
| bool operator!=(const iterator& other) const { return it != other.it; } | ||
| }; | ||
| iterator begin() { return iterator(data.begin()); } | ||
| iterator end() { return iterator(data.end()); } | ||
| }; |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Collaborator
Author
There was a problem hiding this comment.
Nevermind, I think pimpl will be the cleaner way (and also easier for us, in case we need to add a new utility function into server_context)
Will implement this in my next commit
Collaborator
Author
There was a problem hiding this comment.
Implemented in 9a7b4f3 :
server_contextis moved toserver_context_impl(just renaming struct, the code is left untouched)- the new
server_contextonly expose: init(), load_model(), start_loop(), terminate()
@ggerganov Would be nice if you can review it in a short time frame (ideally before #17470 as some conflicts are inevitable). Thanks!
22039aa to
9a7b4f3
Compare
ggerganov
approved these changes
Nov 29, 2025
Collaborator
Author
|
Nice, thanks for the speedy review! |
5f7b502 to
c5f8cdf
Compare
Closed
Anico2
added a commit
to Anico2/llama.cpp
that referenced
this pull request
Jan 15, 2026
* git mv * add server-context.h * add server-context.h * clean up headers * cont : cleanup * also expose server_response_reader (to be used by CLI) * fix windows build * decouple server_routes and server_http --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
blime4
referenced
this pull request
in blime4/llama.cpp
Feb 5, 2026
* git mv * add server-context.h * add server-context.h * clean up headers * cont : cleanup * also expose server_response_reader (to be used by CLI) * fix windows build * decouple server_routes and server_http --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
Seunghhon
pushed a commit
to Seunghhon/llama.cpp
that referenced
this pull request
Apr 26, 2026
* git mv * add server-context.h * add server-context.h * clean up headers * cont : cleanup * also expose server_response_reader (to be used by CLI) * fix windows build * decouple server_routes and server_http --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
ljubomirj
pushed a commit
to ljubomirj/llama.cpp
that referenced
this pull request
May 6, 2026
* git mv * add server-context.h * add server-context.h * clean up headers * cont : cleanup * also expose server_response_reader (to be used by CLI) * fix windows build * decouple server_routes and server_http --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
my-other-github-account
pushed a commit
to my-other-github-account/llama.cpp
that referenced
this pull request
May 15, 2026
* git mv * add server-context.h * add server-context.h * clean up headers * cont : cleanup * also expose server_response_reader (to be used by CLI) * fix windows build * decouple server_routes and server_http --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
my-other-github-account
pushed a commit
to my-other-github-account/llama.cpp
that referenced
this pull request
May 15, 2026
* git mv * add server-context.h * add server-context.h * clean up headers * cont : cleanup * also expose server_response_reader (to be used by CLI) * fix windows build * decouple server_routes and server_http --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
phibya
pushed a commit
to ziee-ai/llama.cpp
that referenced
this pull request
May 29, 2026
* git mv * add server-context.h * add server-context.h * clean up headers * cont : cleanup * also expose server_response_reader (to be used by CLI) * fix windows build * decouple server_routes and server_http --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
fewtarius
pushed a commit
to fewtarius/CachyLLama
that referenced
this pull request
May 30, 2026
* git mv * add server-context.h * add server-context.h * clean up headers * cont : cleanup * also expose server_response_reader (to be used by CLI) * fix windows build * decouple server_routes and server_http --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
fukuro-kun
pushed a commit
to fukuro-kun/fukuro-llama-cpp-turboquant
that referenced
this pull request
Jul 5, 2026
* git mv * add server-context.h * add server-context.h * clean up headers * cont : cleanup * also expose server_response_reader (to be used by CLI) * fix windows build * decouple server_routes and server_http --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
MrLordCat
referenced
this pull request
in MrLordCat/llama.cpp-with-GUI
Jul 16, 2026
* git mv * add server-context.h * add server-context.h * clean up headers * cont : cleanup * also expose server_response_reader (to be used by CLI) * fix windows build * decouple server_routes and server_http --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extracted part of the changes in #17554 into this dedicated PR, just in case something goes wrong it's easier to trace back.
Compare to the proposed approach in the mentioned PR, which simply move everything to
.h, this PR do some extra thing:git mv, so that auto-merge can be more happy (I hope so, will need to test)server-context.h; so for example,server_slotis now a private implementationserver_context, consolidate everything into 4 main functions:init(),load_model(),start_loop(),terminate()This should allow easier integration of server inside CLI, while allow downstream to incorporate server as a library (cc @bandoti , probably pre-cursor to llamax)