-
-
Notifications
You must be signed in to change notification settings - Fork 43
Support ollama #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support ollama #193
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{{- if .Values.backendRuntime.install -}} | ||
apiVersion: inference.llmaz.io/v1alpha1 | ||
kind: BackendRuntime | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: backendruntime | ||
app.kubernetes.io/part-of: llmaz | ||
app.kubernetes.io/created-by: llmaz | ||
name: ollama | ||
spec: | ||
commands: | ||
- sh | ||
- -c | ||
image: ollama/ollama | ||
version: latest | ||
# Do not edit the preset argument name unless you know what you're doing. | ||
# Free to add more arguments with your requirements. | ||
args: | ||
- name: default | ||
flags: | ||
- "ollama serve & | ||
while true; do output=$(ollama list 2>&1); | ||
if ! echo $output | grep -q 'could not connect to ollama app' && echo $output | grep -q 'NAME';then echo 'ollama is running';break; else echo 'Waiting for the ollama to be running...';sleep 1;fi;done; | ||
ollama run {{`{{ .ModelName }}`}}; | ||
while true;do sleep 60;done" | ||
envs: | ||
- name: OLLAMA_HOST | ||
value: 0.0.0.0:8080 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OLLAMA_HOST can expose custom port There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great |
||
resources: | ||
requests: | ||
cpu: 2 | ||
memory: 4Gi | ||
limits: | ||
cpu: 2 | ||
memory: 4Gi | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: llmaz.io/v1alpha1 | ||
kind: OpenModel | ||
metadata: | ||
name: qwen2-0--5b | ||
spec: | ||
familyName: qwen2 | ||
source: | ||
uri: ollama://qwen2:0.5b |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: inference.llmaz.io/v1alpha1 | ||
kind: Playground | ||
metadata: | ||
name: qwen2-0--5b | ||
spec: | ||
replicas: 1 | ||
modelClaim: | ||
modelName: qwen2-0--5b | ||
backendRuntimeConfig: | ||
name: ollama |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,18 +26,23 @@ import ( | |
var _ ModelSourceProvider = &URIProvider{} | ||
|
||
const ( | ||
OSS = "OSS" | ||
OSS = "OSS" | ||
OLLAMA = "OLLAMA" | ||
) | ||
|
||
type URIProvider struct { | ||
modelName string | ||
protocol string | ||
bucket string | ||
endpoint string | ||
modelPath string | ||
modelName string | ||
protocol string | ||
bucket string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We may need to refactor this part in the future, divide the URIProvider to more specified ones, but not a hurry. |
||
endpoint string | ||
modelPath string | ||
modelAddress string | ||
} | ||
|
||
func (p *URIProvider) ModelName() string { | ||
if p.protocol == OLLAMA { | ||
return p.modelAddress | ||
} | ||
return p.modelName | ||
} | ||
|
||
|
@@ -58,6 +63,9 @@ func (p *URIProvider) ModelPath() string { | |
} | ||
|
||
func (p *URIProvider) InjectModelLoader(template *corev1.PodTemplateSpec, index int) { | ||
if p.protocol == OLLAMA { | ||
return | ||
} | ||
initContainerName := MODEL_LOADER_CONTAINER_NAME | ||
if index != 0 { | ||
initContainerName += "-" + strconv.Itoa(index) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: inference.llmaz.io/v1alpha1 | ||
kind: BackendRuntime | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: backendruntime | ||
app.kubernetes.io/part-of: llmaz | ||
app.kubernetes.io/created-by: llmaz | ||
name: ollama | ||
spec: | ||
commands: | ||
- sh | ||
- -c | ||
image: ollama/ollama | ||
version: latest | ||
args: | ||
- name: default | ||
flags: | ||
- "ollama serve & | ||
while true; do output=$(ollama list 2>&1); | ||
if ! echo $output | grep -q 'could not connect to ollama app' && echo $output | grep -q 'NAME';then echo 'ollama is running';break; else echo 'Waiting for the ollama to be running...';sleep 1;fi;done; | ||
ollama run {{`{{ .ModelName }}`}}; | ||
while true;do sleep 60;done" | ||
resources: | ||
requests: | ||
cpu: 2 | ||
memory: 4Gi | ||
limits: | ||
cpu: 2 | ||
memory: 4Gi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to support readiness and liveness next, see #21, but this is ok for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's support probe in the future