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.
This pull request adds a
taggui/run_server.py
which starts a FastAPI server on port11435
and provides a command-line and HTTP interface to make requests to the server. The command-line and API structure follows Ollama.Ollama keeps a model loaded and serves it via a HTTP server. Default settings are loaded from modelfiles. Requests are made via
/api/generate
which also accepts optional settings as json. Settings are stateful and any change is reflected in subsequent calls. Ollama also implements some vision models (like Llava, Moondream...) but relies entirely on Llama.cpp as the model loader backend, which is very flexible and fast, but also why CogVLM2 is not supported yet.This implementation only provides the bare minimum
serve
,run
and/api/generate
. I duplicatedCaptioningThread
intoCaptioningCore
, stripped everythingQt
, while keeping the code as unchanged as possible. Because Ollama expects an array of base64 encoded image I also stripped any reference toimg_path
andimg_tags
(i.e.replace_template_variable
). (To be precise, Ollama expects an array of base64 encoded images of which only the first one is used for most vision models. I duplicated this behaviour.)(If you get an error
Argument list too long
it's probably because your image is too big and base64 expansion exceeds the character length in the terminal.)The idea is to extract the model loader part from the rest and provide a minimal interface. Requests can be made entirely via HTTP which allows more flexibility for UI application and automatization while the server keeps the model loaded independent of any UI application as long as the server is running.