Repository navigation
Install Ollama models from the API and list downloadable models - #733
Conversation
How to try itPowerShell (with the bundled Ollama running): # 1. Remove an installable model that is not the default
docker exec fireform-ollama ollama rm qwen2.5:3b
# 2. It now shows under "downloadable" (installed: false), not under "models"
Invoke-RestMethod "http://localhost:8000/api/v1/system/llm/models?refresh=true" | ConvertTo-Json -Depth 8
# 3. Pull it back. The stream is printed when it finishes and ends with one success line
$body = @{ model = "qwen2.5:3b" } | ConvertTo-Json
(Invoke-WebRequest -Uri "http://localhost:8000/api/v1/system/llm/pull" -Method Post -ContentType "application/json" -Body $body).Content
# 4. It is now under "models" with installed: true, no refresh needed
Invoke-RestMethod "http://localhost:8000/api/v1/system/llm/models" | ConvertTo-Json -Depth 8 |
Provider credentials from the API: detailsThe scope grew, so I'm re-requesting review. The overview is in the description; these are the technical details. How it fits with #725
Technical
Limits (also in the docs)
Testing
The frontend (Settings form for the key, model list, manual model and consent) follows in fireform-frontend. Follow-up: filter non-text Gemini modelsGemini's Regression tests cover the expected Gemini catalog (46 IDs, with exactly 21 retained), fragment-boundary matching, and manually added models. The multi-LLM documentation has also been updated. |
|
Hey @jansans04, nice work on these! I pulled #733 and fireform-frontend#46 locally and tested them together. Both build and run with native Ollama, the models list shows installed vs. downloadable, and pull validation rejects bad names and non-Ollama providers as expected. Both have conflicts with their base branches now, though:
Could you rebase or merge the base into both when you get a chance? I'm thinking #733 goes in first since #46 needs the pull endpoint. |
|
Thanks @vharkins1 for testing them together. Both branches are now up to date with their base and the conflicts are resolved. |
vharkins1
left a comment
There was a problem hiding this comment.
Hey @jansans04, tested this together with fireform-frontend#46 on my machine and it all works!
Install Ollama models and configure LLM providers from the API
Backend for the model picker of #502, built on the multi-LLM layer from #725. Replaces #721.
This PR has two parts: installing Ollama models, and configuring provider credentials from the API. The technical details of the second part are in the comment below.
Why
.env, so changing or adding a key means editing a file and restarting the containers.What changed
Installing Ollama models:
POST /api/v1/system/llm/pulltakes{model, provider?}and streams Ollama's progress as NDJSON. Only Ollama can pull: any other provider, or Ollama being off, is a 422LLM_NOT_AVAILABLE. Ollama not answering before the stream starts is a 503LLM_UNAVAILABLE.{"status":"success"}and noerrorline. If the stream ends without either, or fails midway, the last line is anerrorand there is no success line, since the HTTP status is already 200. The Ollama catalog cache is refreshed before the success line is sent, so the model shows up inGET /system/llm/modelsstraight away.OLLAMA_MODELS, the names in that list; withOLLAMA_MODELS=*,OLLAMA_INSTALLABLE_MODELSor a built-in default (qwen2.5:1.5b,qwen2.5:3b,qwen2.5:7b,llama3.2:3b). A name outside that set cannot be pulled.GET /api/v1/system/llm/models: Ollama models now carryinstalled: true, and Ollama gets a separatedownloadablelist (name,installed: false) with models that can be pulled and are not on the host. It is left out when empty and for other providers.modelsstill holds only what can run, soregistry.resolve()and fills behave as before.OLLAMA_PULL_TIMEOUT(default 120) is how long to wait for data from Ollama without receiving any, not a limit on the whole download. Connecting is limited to 10 s.OLLAMA_INSTALLABLE_MODELSis new. Both are indocker/.env.example.Provider credentials from the API (details in the comment below):
customserver.006, and a new dependency:cryptography.Contracts and
docs/multi-llm-support/are updated for both parts.Notes
/forms/pull,GET /forms/modelswithrecommended, andMODEL_NOT_INSTALLEDare not part of this PR. feat: support LLM providers other than Ollama on development #725's codes apply instead: a fill that names a model Ollama does not offer is a 422LLM_NOT_AVAILABLE, andLLM_MODEL_NOT_FOUNDcovers Ollama answering 404. There is norecommendedfield, sincedefault_modelalready says which model is the default.installedare Ollama specific and live inOllamaLLM. Hosted providers are unaffected.Testing
python -m pytest: 376 passed (302 ondevelopment).qwen2.5:3b(it moved frommodelstodownloadable), pulled it back throughPOST /system/llm/pull(the stream ended with a single success line and the model showed as installed). WithOLLAMA_PULL_TIMEOUT=15, a pull that took 65 s still finished. When Ollama failed at the manifest step, the stream ended with an error line and no success line.Part of #502