FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
genai-stack/pull_model.Dockerfile at main · docker/genai-stack · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
docker
/
genai-stack
Public
Notifications
You must be signed in to change notification settings
Fork
1.2k
Star
5.4k
Code
Issues
61
Pull requests
38
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
genai-stack
/
pull_model.Dockerfile
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (36 loc) · 1.95 KB
Breadcrumbs
genai-stack
/
pull_model.Dockerfile
Copy path
File metadata and controls
45 lines (36 loc) · 1.95 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#
syntax = docker/dockerfile:1.4
FROM
ollama/ollama:latest AS ollama
FROM
babashka/babashka:latest
#
just using as a client - never as a server
COPY
--from=ollama /bin/ollama ./bin/ollama
COPY
<<EOF pull_model.clj
(ns pull-model
(:require [babashka.process :as process]
[clojure.core.async :as async]))
(try
(let [llm (get (System/getenv)
"LLM"
)
url (get (System/getenv)
"OLLAMA_BASE_URL"
)]
(println (format
"pulling ollama model %s using %s"
llm url))
(if (and llm
url
(not (#{
"gpt-4"
"gpt-3.5"
"claudev2"
"gpt-4o"
"gpt-4-turbo"
} llm))
(not (some #(.startsWith llm %) [
"ai21.jamba-instruct-v1:0"
"amazon.titan"
"anthropic.claude"
"cohere.command"
"meta.llama"
"mistral.mi"
])))
;; ----------------------------------------------------------------------
;; just call `ollama pull` here - create OLLAMA_HOST from OLLAMA_BASE_URL
;; ----------------------------------------------------------------------
;; TODO - this still doesn
't show progress properly when run from docker compose
(let [done (async/chan)]
(async/go-loop [n 0]
(let [[v _] (async/alts! [done (async/timeout 5000)])]
(if (= :stop v) :stopped (do (println (format "... pulling model (%ss) - will take several minutes" (* n 10))) (recur (inc n))))))
(process/shell {:env {"OLLAMA_HOST" url "HOME" (System/getProperty "user.home")} :out :inherit :err :inherit} (format "bash -c '
./bin/ollama show %s --modelfile > /dev/null || ./bin/ollama pull %s
'" llm llm))
(async/>!! done :stop))
(println "OLLAMA model only pulled if both LLM and OLLAMA_BASE_URL are set and the LLM model is not gpt")))
(catch Throwable _ (System/exit 1)))
EOF
ENTRYPOINT ["bb", "-f", "pull_model.clj"]
Back
|
FazBrowse Home
|
New Git URL