Skip to content

Commit eddd9d9

Browse files
committed
clone localai func
Signed-off-by: Sertac Ozercan <[email protected]>
1 parent c1b47bd commit eddd9d9

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

pkg/aikit2llb/convert.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,13 @@ func installCuda(c *config.Config, s llb.State, merge llb.State) (llb.State, llb
158158
}
159159

160160
func installExllama(c *config.Config, s llb.State, merge llb.State) llb.State {
161-
backend := "exllama"
161+
backend := utils.BackendExllama
162162
exllamaRepo := "https://github.com/turboderp/exllama"
163163
exllamaTag := "master"
164164
for b := range c.Backends {
165165
if c.Backends[b] == utils.BackendExllamaV2 {
166166
exllamaRepo = "https://github.com/turboderp/exllamav2"
167-
backend = "exllama2"
167+
backend = utils.BackendExllamaV2
168168
exllamaTag = "v0.0.11"
169169
}
170170
}
@@ -173,7 +173,7 @@ func installExllama(c *config.Config, s llb.State, merge llb.State) llb.State {
173173
s = s.Run(sh("apt-get update && apt-get install --no-install-recommends -y git ca-certificates python3-pip python3-dev g++ && apt-get clean"), llb.IgnoreCache).Root()
174174

175175
// clone localai exllama backend only
176-
s = s.Run(shf("git clone --filter=blob:none --no-checkout %[1]s /tmp/localai/ && cd /tmp/localai && git sparse-checkout init --cone && git sparse-checkout set backend/python/%[2]s && git checkout %[3]s && rm -rf .git", localAIRepo, backend, localAIVersion)).Root()
176+
s = cloneLocalAI(s, backend)
177177

178178
// clone exllama to localai exllama backend path and install python dependencies
179179
s = s.Run(shf("git clone --depth 1 %[1]s --branch %[2]s /tmp/%[3]s && mv /tmp/%[3]s/* /tmp/localai/backend/python/%[3]s && rm -rf /tmp/%[3]s && cd /tmp/localai/backend/python/%[3]s && rm -rf .git && pip3 install grpcio protobuf typing-extensions sympy mpmath setuptools numpy --break-system-packages && pip3 install -r /tmp/localai/backend/python/%[3]s/requirements.txt --break-system-packages", exllamaRepo, exllamaTag, backend)).Root()
@@ -183,12 +183,11 @@ func installExllama(c *config.Config, s llb.State, merge llb.State) llb.State {
183183
}
184184

185185
func installMamba(s llb.State, merge llb.State) llb.State {
186-
backend := "mamba"
187186
savedState := s
188187
// libexpat1 is requirement but git is not. however libexpat1 is a dependency of git
189188
s = s.Run(sh("apt-get install --no-install-recommends -y git python3 python3-dev python3-pip libssl3 openssl && apt-get clean"), llb.IgnoreCache).Root()
190189

191-
s = s.Run(shf("git clone --filter=blob:none --no-checkout %[1]s /tmp/localai/ && cd /tmp/localai && git sparse-checkout init --cone && git sparse-checkout set backend/python/%[2]s && git checkout %[3]s && rm -rf .git", localAIRepo, backend, localAIVersion)).Root()
190+
s = cloneLocalAI(s, utils.BackendMamba)
192191

193192
s = s.Run(shf("pip3 install packaging numpy torch==2.1.0 grpcio protobuf --break-system-packages && pip3 install causal-conv1d==1.0.0 mamba-ssm==1.0.1 --break-system-packages")).Root()
194193

@@ -249,6 +248,10 @@ func addLocalAI(c *config.Config, s llb.State, merge llb.State) (llb.State, llb.
249248
return s, llb.Merge([]llb.State{merge, diff})
250249
}
251250

251+
func cloneLocalAI(s llb.State, backend string) llb.State {
252+
return s.Run(shf("git clone --filter=blob:none --no-checkout %[1]s /tmp/localai/ && cd /tmp/localai && git sparse-checkout init --cone && git sparse-checkout set backend/python/%[2]s && git checkout %[3]s && rm -rf .git", localAIRepo, backend, localAIVersion)).Root()
253+
}
254+
252255
func shf(cmd string, v ...interface{}) llb.RunOption {
253256
return llb.Args([]string{"/bin/sh", "-c", fmt.Sprintf(cmd, v...)})
254257
}

0 commit comments

Comments
 (0)