Skip to content

Commit

Permalink
refactor: pass ollama url in env
Browse files Browse the repository at this point in the history
  • Loading branch information
Apoorva64 committed Oct 20, 2024
1 parent 574c522 commit b8eda45
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion api/v1/model_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ type ModelSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

OllamaUrl string `json:"ollamaUrl"`
ModelName string `json:"modelName"`
}

Expand Down
3 changes: 0 additions & 3 deletions config/crd/bases/ollama.ollama.startupnation_models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ spec:
properties:
modelName:
type: string
ollamaUrl:
type: string
required:
- modelName
- ollamaUrl
type: object
status:
description: ModelStatus defines the observed state of Model
Expand Down
9 changes: 8 additions & 1 deletion internal/controller/model_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log"

ollamav1 "github.com/StartUpNationLabs/simple-ollama-operator/api/v1"
"os"
)

// ModelReconciler reconciles a Model object
Expand Down Expand Up @@ -56,9 +57,15 @@ func (r *ModelReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
logger.Error(err, "unable to fetch Model")
return ctrl.Result{}, client.IgnoreNotFound(err)
}
// Read url from the Model instance
modelUrl := os.Getenv("OLLAMA_URL")
if modelUrl == "" {
logger.Error(err, "unable to fetch Ollama URL")
panic("OLLAMA_URL not set")
}

// create a new Ollama Client
ollamaClient, err := ollama_client.NewClientWithResponses(model.Spec.OllamaUrl)
ollamaClient, err := ollama_client.NewClientWithResponses(modelUrl)
if err != nil {
logger.Error(err, "unable to create Ollama Client")
return ctrl.Result{}, err
Expand Down

0 comments on commit b8eda45

Please sign in to comment.